Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions sdk/example-app/src/extension-example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async function main(): Promise<void> {

const tx = new Transaction();

tx.add(client.pas.tx.sendBalance({
tx.add(client.pas.call.sendBalance({
from: sender, // sender here.
to: '0x2', // receiver here.
amount: 1_000_000, // 1 demoUSD
Expand Down Expand Up @@ -96,7 +96,7 @@ async function finalizeTestAssetSetup(client: PasClientType) {

async function createAccountForAddress(client: PasClientType, address: string) {
const tx = new Transaction();
tx.add(client.pas.tx.accountForAddress(address));
tx.add(client.pas.call.accountForAddress(address));
return signAndExecute(client, tx);
}

Expand Down
7 changes: 2 additions & 5 deletions sdk/pas/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@

import type { ClientWithCoreApi } from '@mysten/sui/client';

import {
MAINNET_PAS_PACKAGE_CONFIG,
TESTNET_PAS_PACKAGE_CONFIG,
} from './constants.js';
import { MAINNET_PAS_PACKAGE_CONFIG, TESTNET_PAS_PACKAGE_CONFIG } from './constants.js';
import {
deriveAccountAddress,
derivePolicyAddress,
Expand Down Expand Up @@ -134,7 +131,7 @@ export class PASClient {
* that registers a `$Intent` placeholder in the transaction. The actual PTB commands
* are resolved lazily at `tx.build()` time via the shared PAS resolver plugin.
*/
get tx() {
get call() {
return {
/**
* Creates a transfer funds intent. At build time, it auto-resolves the issuer's
Expand Down
14 changes: 9 additions & 5 deletions sdk/pas/src/contracts/pas/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ export interface ShareOptions {
arguments: ShareArguments | [account: RawTransactionArgument<string>];
}
/**
* The only way to finalize the TX is by sharing the account. All accounts are shared
* by default.
* The only way to finalize the TX is by sharing the account. All accounts are
* shared by default.
*/
export function share(options: ShareOptions) {
const packageAddress = options.package ?? '@mysten/pas';
Expand Down Expand Up @@ -220,8 +220,8 @@ export interface UnsafeSendBalanceOptions {
typeArguments: [string];
}
/**
* Transfer `amount` from account to an address. This unlocks transfers to a account
* before it has been created.
* Transfer `amount` from account to an address. This unlocks transfers to a
* account before it has been created.
*
* It's marked as `unsafe_` as it's easy to accidentally pick the wrong recipient
* address.
Expand Down Expand Up @@ -260,7 +260,11 @@ export interface NewAuthAsObjectOptions {
package?: string;
arguments: NewAuthAsObjectArguments | [uid: RawTransactionArgument<string>];
}
/** Generate an ownership proof from a `UID` object, to allow objects to own accounts. */
/**
* Generate an ownership proof from a `UID` object, to allow objects to own
* accounts. `&mut UID` is intentional — it serves as proof of ownership over the
* object.
*/
export function newAuthAsObject(options: NewAuthAsObjectOptions) {
const packageAddress = options.package ?? '@mysten/pas';
const argumentsTypes = ['0x2::object::ID'] satisfies (string | null)[];
Expand Down
2 changes: 1 addition & 1 deletion sdk/pas/src/contracts/pas/policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export interface SyncVersioningOptions {
}
/**
* Allows syncing the versioning of a policy to the namespace's versioning. This is
* permission-less and can be done
* permission-less and can be done by anyone.
*/
export function syncVersioning(options: SyncVersioningOptions) {
const packageAddress = options.package ?? '@mysten/pas';
Expand Down
8 changes: 8 additions & 0 deletions sdk/pas/src/contracts/pas/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ import { type Transaction } from '@mysten/sui/transactions';
import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';

const $moduleName = '@mysten/pas::templates';
export const PAS = new MoveStruct({
name: `${$moduleName}::PAS`,
fields: {
dummy_field: bcs.bool(),
},
});
export const Templates = new MoveStruct({
name: `${$moduleName}::Templates`,
fields: {
Expand All @@ -28,6 +34,7 @@ export interface SetupOptions {
package?: string;
arguments: SetupArguments | [namespace: RawTransactionArgument<string>];
}
/** Create the templates registry */
export function setup(options: SetupOptions) {
const packageAddress = options.package ?? '@mysten/pas';
const argumentsTypes = [null] satisfies (string | null)[];
Expand Down Expand Up @@ -56,6 +63,7 @@ export interface SetTemplateCommandOptions {
];
typeArguments: [string];
}
/** Sets the PTB template for a given Action. */
export function setTemplateCommand(options: SetTemplateCommandOptions) {
const packageAddress = options.package ?? '@mysten/pas';
const argumentsTypes = [null, null, null] satisfies (string | null)[];
Expand Down
2 changes: 1 addition & 1 deletion sdk/pas/src/contracts/pas/unlock_funds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function UnlockFunds<T extends BcsType<any>>(...typeParameters: [T]) {
return new MoveStruct({
name: `${$moduleName}::UnlockFunds<${typeParameters[0].name as T['name']}>`,
fields: {
/** `from` is the wallet OR object address, NOT the account address */
/** `owner` is the wallet OR object address, NOT the account address */
owner: bcs.Address,
/** The ID of the account the funds are coming from */
account_id: bcs.Address,
Expand Down
103 changes: 85 additions & 18 deletions sdk/pas/src/contracts/ptb/ptb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ import {
} from '../utils/index.js';

const $moduleName = '@mysten/ptb::ptb';
export const Command = new MoveTuple({
name: `${$moduleName}::Command`,
fields: [bcs.u8(), bcs.vector(bcs.u8())],
});
export const Transaction = new MoveStruct({
name: `${$moduleName}::Transaction`,
fields: {
commands: bcs.vector(Command),
},
});
/**
* Defines a simplified `ObjectArg` type for the `Transaction`.
*
Expand Down Expand Up @@ -86,25 +96,12 @@ export const CallArg = new MoveEnum({
/**
* Extended arguments for off-chain resolution. Can be created and registered in a
* transaction through `ext_input`.
*
* Extended arguments are namespaced by Type associated with them. In an
* application, this can be the root object, or a special type used for off chain
* resolution.
*/
Ext: new MoveStruct({
name: `CallArg.Ext`,
fields: {
namespace: bcs.string(),
value: bcs.string(),
},
}),
},
});
export const Command = new MoveTuple({
name: `${$moduleName}::Command`,
fields: [bcs.u8(), bcs.vector(bcs.u8())],
});
export const Transaction = new MoveStruct({
name: `${$moduleName}::Transaction`,
fields: {
inputs: bcs.vector(CallArg),
commands: bcs.vector(Command),
Ext: new MoveTuple({ name: `CallArg.Ext`, fields: [bcs.string(), bcs.string()] }),
},
});
/** Defines a simplified `Argument` type for the `Transaction`. */
Expand Down Expand Up @@ -232,6 +229,48 @@ export function display(options: DisplayOptions = {}) {
function: 'display',
});
}
export interface DenyListOptions {
package?: string;
arguments?: [];
}
/** Shorthand for `object_by_id` with `0x403` (DenyList). */
export function denyList(options: DenyListOptions = {}) {
const packageAddress = options.package ?? '@mysten/ptb';
return (tx: Transaction_1) =>
tx.moveCall({
package: packageAddress,
module: 'ptb',
function: 'deny_list',
});
}
export interface CoinRegistryOptions {
package?: string;
arguments?: [];
}
/** Shorthand for `object_by_id` with `0xC` (CoinRegistry). */
export function coinRegistry(options: CoinRegistryOptions = {}) {
const packageAddress = options.package ?? '@mysten/ptb';
return (tx: Transaction_1) =>
tx.moveCall({
package: packageAddress,
module: 'ptb',
function: 'coin_registry',
});
}
export interface AccumulatorRootOptions {
package?: string;
arguments?: [];
}
/** Shorthand for `object_by_id` with `0xACC` (AccumulatorRoot). */
export function accumulatorRoot(options: AccumulatorRootOptions = {}) {
const packageAddress = options.package ?? '@mysten/ptb';
return (tx: Transaction_1) =>
tx.moveCall({
package: packageAddress,
module: 'ptb',
function: 'accumulator_root',
});
}
export interface GasOptions {
package?: string;
arguments?: [];
Expand Down Expand Up @@ -449,6 +488,7 @@ export interface ExtInputArguments {
export interface ExtInputOptions {
package?: string;
arguments: ExtInputArguments | [name: RawTransactionArgument<string>];
typeArguments: [string];
}
/**
* Create an external input handler. Expected to be understood by the off-chain
Expand All @@ -464,6 +504,33 @@ export function extInput(options: ExtInputOptions) {
module: 'ptb',
function: 'ext_input',
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
typeArguments: options.typeArguments,
});
}
export interface ExtInputRawArguments {
namespace: RawTransactionArgument<string>;
name: RawTransactionArgument<string>;
}
export interface ExtInputRawOptions {
package?: string;
arguments:
| ExtInputRawArguments
| [namespace: RawTransactionArgument<string>, name: RawTransactionArgument<string>];
}
/**
* Create an external input handler for a given type T. This can be used to
* hardcode the namespace value without having access to `T`.
*/
export function extInputRaw(options: ExtInputRawOptions) {
const packageAddress = options.package ?? '@mysten/ptb';
const argumentsTypes = ['0x1::string::String', '0x1::string::String'] satisfies (string | null)[];
const parameterNames = ['namespace', 'name'];
return (tx: Transaction_1) =>
tx.moveCall({
package: packageAddress,
module: 'ptb',
function: 'ext_input_raw',
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
});
}
export interface CommandArguments {
Expand Down
5 changes: 1 addition & 4 deletions sdk/pas/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,5 @@

export { PASClient, pas } from './client.js';
export type { PASClientConfig, PASPackageConfig, PASOptions } from './types.js';
export {
TESTNET_PAS_PACKAGE_CONFIG,
MAINNET_PAS_PACKAGE_CONFIG,
} from './constants.js';
export { TESTNET_PAS_PACKAGE_CONFIG, MAINNET_PAS_PACKAGE_CONFIG } from './constants.js';
export * from './error.js';
4 changes: 2 additions & 2 deletions sdk/pas/src/resolution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ export function buildMoveCallCommandFromTemplate(
} else if (arg.Input.Ext) {
resolvedArgs.push(
resolveRawPasRequest(args, {
_namespace: arg.Input.Ext.namespace,
value: arg.Input.Ext.value,
_namespace: arg.Input.Ext[0],
value: arg.Input.Ext[1],
}),
);
} else {
Expand Down
10 changes: 5 additions & 5 deletions sdk/pas/test/e2e/data/demo_usd/Move.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,31 @@
version = 4

[pinned.testnet.MoveStdlib]
source = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/move-stdlib", rev = "868c226359ef914f1f3b080518f27eb13d8967f5" }
source = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/move-stdlib", rev = "b38bca86f0323b3fe8b6b7f4ca0cd7ae7faebe4b" }
use_environment = "testnet"
manifest_digest = "C4FE4C91DE74CBF223B2E380AE40F592177D21870DC2D7EB6227D2D694E05363"
deps = {}

[pinned.testnet.Sui]
source = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "868c226359ef914f1f3b080518f27eb13d8967f5" }
source = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "b38bca86f0323b3fe8b6b7f4ca0cd7ae7faebe4b" }
use_environment = "testnet"
manifest_digest = "7AFB66695545775FBFBB2D3078ADFD084244D5002392E837FDE21D9EA1C6D01C"
deps = { MoveStdlib = "MoveStdlib" }

[pinned.testnet.demo_usd]
source = { root = true }
use_environment = "testnet"
manifest_digest = "F3F3BE825FCACCADB2ECE4ADCDD2DA4CD2C8D0DDAC32D4F23CBCE3F2760282C5"
manifest_digest = "31F68DEA541AB27E322EFF2DDC82ABB0893418A6E8B029F2FD0E0F80D7FE263B"
deps = { pas = "pas", ptb = "ptb", std = "MoveStdlib", sui = "Sui" }

[pinned.testnet.pas]
source = { local = "../pas" }
source = { git = "https://github.com/mystenlabs/pas.git", subdir = "packages/pas", rev = "b710e43a555bb66ec6d5288441a25b41c2d339f2" }
use_environment = "testnet"
manifest_digest = "38AA62656ABE7551C444DA427ADBAA7751CB67250663D39FCDE36E938138EA7D"
deps = { ptb = "ptb", std = "MoveStdlib", sui = "Sui" }

[pinned.testnet.ptb]
source = { local = "../ptb" }
source = { git = "https://github.com/mystenlabs/pas.git", subdir = "packages/ptb", rev = "b710e43a555bb66ec6d5288441a25b41c2d339f2" }
use_environment = "testnet"
manifest_digest = "5745706258F61D6CE210904B3E6AE87A73CE9D31A6F93BE4718C442529332A87"
deps = { std = "MoveStdlib", sui = "Sui" }
5 changes: 3 additions & 2 deletions sdk/pas/test/e2e/data/demo_usd/Move.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ name = "demo_usd"
edition = "2024.beta"

[dependencies]
pas = { local = "../pas" }
ptb = { local = "../ptb" }
# testnet v1
pas = { git = "https://github.com/mystenlabs/pas.git", subdir = "packages/pas", rev = "b710e43a555bb66ec6d5288441a25b41c2d339f2" }
ptb = { git = "https://github.com/mystenlabs/pas.git", subdir = "packages/ptb", rev = "b710e43a555bb66ec6d5288441a25b41c2d339f2" }
Loading
Loading