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/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
"author": "Mysten Labs",
"license": "Apache-2.0",
"devDependencies": {
"@mysten/sui": "^2.4.0",
"@mysten/sui": "^2.6.0",
"@mysten/bcs": "^2.0.2",
"@mysten/codegen": "^0.6.0"
},
"peerDependencies": {
"@mysten/sui": "^2.4.0",
"@mysten/sui": "^2.6.0",
"@mysten/bcs": "^2.0.2"
}
}
5 changes: 4 additions & 1 deletion sdk/pas/src/contracts/pas/keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import { MoveTuple, normalizeMoveArguments, type RawTransactionArgument } from '

const $moduleName = '@mysten/pas::keys';
export const PolicyKey = new MoveTuple({ name: `${$moduleName}::PolicyKey`, fields: [bcs.bool()] });
export const AccountKey = new MoveTuple({ name: `${$moduleName}::AccountKey`, fields: [bcs.Address] });
export const AccountKey = new MoveTuple({
name: `${$moduleName}::AccountKey`,
fields: [bcs.Address],
});
export const TemplateKey = new MoveTuple({
name: `${$moduleName}::TemplateKey`,
fields: [bcs.bool()],
Expand Down
18 changes: 12 additions & 6 deletions sdk/pas/src/resolution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,12 @@ export function buildMoveCallCommandFromTemplate(
);
}
} else if (arg.Input.Ext) {
resolvedArgs.push(resolveRawPasRequest(args, {
_namespace: arg.Input.Ext.namespace,
value: arg.Input.Ext.value,
}));
resolvedArgs.push(
resolveRawPasRequest(args, {
_namespace: arg.Input.Ext.namespace,
value: arg.Input.Ext.value,
}),
);
} else {
throw new PASClientError(`Unsupported input kind: ${arg.Input.$kind}`);
}
Expand All @@ -224,7 +226,10 @@ export function buildMoveCallCommandFromTemplate(
});
}

function resolveRawPasRequest(args: RawCommandBuildArgs, extInput: { _namespace: string, value: string }): Argument {
function resolveRawPasRequest(
args: RawCommandBuildArgs,
extInput: { _namespace: string; value: string },
): Argument {
// do the logic on `namespace` here
// return error if it's not PAS

Expand All @@ -236,7 +241,8 @@ function resolveRawPasRequest(args: RawCommandBuildArgs, extInput: { _namespace:
if (!args.policy) throw new PASClientError(`Policy is not set in the context.`);
return args.policy;
case 'sender_account':
if (!args.senderAccount) throw new PASClientError(`Sender account is not set in the context.`);
if (!args.senderAccount)
throw new PASClientError(`Sender account is not set in the context.`);
return args.senderAccount;
case 'receiver_account':
if (!args.receiverAccount)
Expand Down
34 changes: 18 additions & 16 deletions sdk/pas/test/e2e/e2e.isolated.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ import { normalizeStructTag, normalizeSuiAddress } from '@mysten/sui/utils';
import { describe, expect, it } from 'vitest';

import { DemoUsdTestHelpers } from './demoUsd.ts';
import { setupToolbox, simulateFailingTransaction, type TestToolbox } from './setup.ts';
import {
executeTransaction,
setupToolbox,
simulateFailingTransaction,
type TestToolbox,
} from './setup.ts';

async function expectBalances(
toolbox: TestToolbox,
Expand Down Expand Up @@ -50,7 +55,10 @@ describe.concurrent(
// Create the account for the address.
await toolbox.createAccountForAddress(toolbox.address());

const { balance: accountBalanceAfterTransfer } = await toolbox.getBalance(accountId, suiTypeName);
const { balance: accountBalanceAfterTransfer } = await toolbox.getBalance(
accountId,
suiTypeName,
);
expect(Number(accountBalanceAfterTransfer.balance)).toBe(1_000_000_000);

// try to do an unlock but it should fail because `policy` for Sui does not exist.
Expand Down Expand Up @@ -84,7 +92,10 @@ describe.concurrent(

await toolbox.executeTransaction(unlockTx);

const { balance: accountBalanceAfterUnlock } = await toolbox.getBalance(accountId, suiTypeName);
const { balance: accountBalanceAfterUnlock } = await toolbox.getBalance(
accountId,
suiTypeName,
);
expect(Number(accountBalanceAfterUnlock.balance)).toBe(0);
});

Expand Down Expand Up @@ -186,9 +197,9 @@ describe.concurrent(
const receiverAccountId = toolbox.client.pas.deriveAccountAddress(receiver);

// Verify neither account exists.
await expect(toolbox.client.core.getObject({ objectId: senderAccountId })).rejects.toThrowError(
'not found',
);
await expect(
toolbox.client.core.getObject({ objectId: senderAccountId }),
).rejects.toThrowError('not found');
await expect(
toolbox.client.core.getObject({ objectId: receiverAccountId }),
).rejects.toThrowError('not found');
Expand Down Expand Up @@ -337,16 +348,7 @@ describe.concurrent(
}),
);

const resp = await toolbox.client.signAndExecuteTransaction({
signer: toolbox.keypair,
transaction,
include: {
effects: true,
},
});

expect(resp.FailedTransaction).toBeDefined();
expect(resp.FailedTransaction!.effects.status.error!.message).toEqual(
expect(executeTransaction(toolbox, transaction)).rejects.toThrowError(
'InsufficientFundsForWithdraw',
);
});
Expand Down
4 changes: 2 additions & 2 deletions sdk/pas/test/e2e/globalSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ declare module 'vitest' {
const SUI_TOOLS_TAG =
process.env.SUI_TOOLS_TAG ||
(process.arch === 'arm64'
? '5ce2a8c246577d36160e296d6051c8f5e59f93b4-arm64'
: '5ce2a8c246577d36160e296d6051c8f5e59f93b4');
? '951cae315d8b252131836a331bcc16b89eb340d6-arm64'
: '951cae315d8b252131836a331bcc16b89eb340d6');

export default async function setup(project: TestProject) {
console.log('Starting test containers');
Expand Down
32 changes: 29 additions & 3 deletions sdk/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading