Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jl/caip multichain/add api specs wallet create session #29592

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
36 changes: 18 additions & 18 deletions test/e2e/api-specs/MultichainAuthorizationConfirmation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,25 +72,25 @@ export class MultichainAuthorizationConfirmation implements Rule {
const isMethodAllowed = this.only ? this.only.includes(method.name) : true;
if (isMethodAllowed) {
if (method.examples) {
// pull the first example
const e = method.examples[0];
const ex = e as ExamplePairingObject;
method.examples.forEach((e) => {
const ex = e as ExamplePairingObject;

if (!ex.result) {
return calls;
}
const p = ex.params.map((_e) => (_e as ExampleObject).value);
const params =
method.paramStructure === 'by-name'
? paramsToObj(p, method.params as ContentDescriptorObject[])
: p;
calls.push({
title: `${this.getTitle()} - with example ${ex.name}`,
methodName: method.name,
params,
url: '',
resultSchema: (method.result as ContentDescriptorObject).schema,
expectedResult: (ex.result as ExampleObject).value,
if (!ex.result) {
return;
}
const p = ex.params.map((_e) => (_e as ExampleObject).value);
const params =
method.paramStructure === 'by-name'
? paramsToObj(p, method.params as ContentDescriptorObject[])
: p;
calls.push({
title: `${this.getTitle()} - with example ${ex.name}`,
methodName: method.name,
params,
url: '',
resultSchema: (method.result as ContentDescriptorObject).schema,
expectedResult: (ex.result as ExampleObject).value,
});
});
} else {
// naively call the method with no params
Expand Down
74 changes: 71 additions & 3 deletions test/e2e/run-api-specs-multichain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ async function main() {
// fix the example for wallet_createSession
(providerAuthorize as MethodObject).examples = [
{
name: 'wallet_createSessionExample',
description: 'Example of a provider authorization request.',
name: 'wallet_createSessionEthExample',
description:
'Example of a provider authorization request with eip155 scopes.',
params: [
{
name: 'requiredScopes',
Expand All @@ -146,7 +147,7 @@ async function main() {
},
],
result: {
name: 'wallet_createSessionResultExample',
name: 'wallet_createSessionEthResultExample',
value: {
sessionScopes: {
[`eip155:${chainId}`]: {
Expand All @@ -168,6 +169,73 @@ async function main() {
},
},
},
{
name: 'wallet_createSessionEthUnsupportedMethodsExample',
description:
'Example of a provider authorization request with unsupported eip155 methods.',
params: [
{
name: 'requiredScopes',
value: {
eip155: {
references: ['1337'],
methods: ['not_supported'],
notifications: [],
},
},
},
],
result: {
name: 'wallet_createSessionEthUnsupportedMethodsResultExample',
value: {
sessionScopes: {
[`eip155:${chainId}`]: {
accounts: [`eip155:${chainId}:${ACCOUNT_1}`],
methods: ethereumMethods,
notifications: ['eth_subscription'],
},
},
},
},
},
{
name: 'wallet_createSessionUnsupportedScopesExample',
description:
'Example of a provider authorization request with unsupported scopes.',
params: [
{
name: 'requiredScopes',
value: {
'foo:bar': {
methods: [],
notifications: [],
},
},
},
],
result: {
name: 'wallet_createSessionUnsupportedScopesResultExample',
value: {
sessionScopes: {
[`eip155:1`]: {
accounts: [`eip155:1:${ACCOUNT_1}`],
methods: ethereumMethods,
notifications: ['eth_subscription'],
},
[`eip155:59144`]: {
accounts: [`eip155:59144:${ACCOUNT_1}`],
methods: ethereumMethods,
notifications: ['eth_subscription'],
},
[`eip155:${chainId}`]: {
accounts: [`eip155:${chainId}:${ACCOUNT_1}`],
methods: ethereumMethods,
notifications: ['eth_subscription'],
},
},
},
},
},
];

const server = mockServer(
Expand Down
Loading