Skip to content

Commit ede0802

Browse files
committed
chore: 🤖 bump the SDK to v29-next.4
also yarn format some files
1 parent 3380a92 commit ede0802

File tree

10 files changed

+653
-299
lines changed

10 files changed

+653
-299
lines changed

‎tests/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
},
4747
"dependencies": {
4848
"@polymeshassociation/local-signing-manager": "^3.5.2",
49-
"@polymeshassociation/polymesh-sdk": "^27.5.1",
49+
"@polymeshassociation/polymesh-sdk": "29.0.0-next.4",
5050
"cross-fetch": "^4.1.0",
5151
"dotenv": "^16.5.0"
5252
},

‎tests/src/__tests__/rest/assets/controllerTransfer.ts‎

Lines changed: 102 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -5,112 +5,121 @@ import { ProcessMode } from '~/rest/common';
55
import { Identity } from '~/rest/identities/interfaces';
66
import { RestSuccessResult } from '~/rest/interfaces';
77
import { fungibleInstructionParams } from '~/rest/settlements/params';
8+
89
import { expectBasicTxInfo } from '../utils';
910

1011
const handles = ['issuer', 'holder'];
1112
let factory: TestFactory;
1213

1314
describe('Fungible AssetController transfer', () => {
14-
let restClient: RestClient;
15-
let signer: string;
16-
let issuer: Identity;
17-
let holder: Identity;
18-
let assetParams: ReturnType<typeof createAssetParams>;
19-
let assetId: string;
20-
21-
beforeAll(async () => {
22-
factory = await TestFactory.create({ handles });
23-
({ restClient } = factory);
24-
issuer = factory.getSignerIdentity(handles[0]);
25-
holder = factory.getSignerIdentity(handles[1]);
26-
27-
signer = issuer.signer;
28-
29-
assetParams = createAssetParams({
30-
options: { processMode: ProcessMode.Submit, signer },
31-
});
15+
let restClient: RestClient;
16+
let signer: string;
17+
let issuer: Identity;
18+
let holder: Identity;
19+
let assetParams: ReturnType<typeof createAssetParams>;
20+
let assetId: string;
21+
22+
beforeAll(async () => {
23+
factory = await TestFactory.create({ handles });
24+
({ restClient } = factory);
25+
issuer = factory.getSignerIdentity(handles[0]);
26+
holder = factory.getSignerIdentity(handles[1]);
27+
28+
signer = issuer.signer;
29+
30+
assetParams = createAssetParams({
31+
options: { processMode: ProcessMode.Submit, signer },
3232
});
33+
});
3334

34-
afterAll(async () => {
35-
await factory.close();
36-
});
35+
afterAll(async () => {
36+
await factory.close();
37+
});
3738

38-
it('should create and fetch the Asset', async () => {
39-
assetId = await restClient.assets.createAndGetAssetId(assetParams);
39+
it('should create and fetch the Asset', async () => {
40+
assetId = await restClient.assets.createAndGetAssetId(assetParams);
4041

41-
const asset = await restClient.assets.getAsset(assetId);
42+
const asset = await restClient.assets.getAsset(assetId);
4243

43-
expect(asset).toMatchObject({
44-
name: assetParams.name,
45-
assetType: assetParams.assetType,
46-
});
44+
expect(asset).toMatchObject({
45+
name: assetParams.name,
46+
assetType: assetParams.assetType,
4747
});
48-
49-
it('should transfer the asset to holder', async () => {
50-
const transferToHolderTx = await restClient.settlements.createDirectInstruction(fungibleInstructionParams(assetId, issuer.did, holder.did, {
51-
options: { processMode: ProcessMode.Submit, signer },
52-
}));
53-
54-
// should have created an instruction
55-
expect((transferToHolderTx as RestSuccessResult).instruction).toBeDefined();
56-
57-
const txData = await restClient.settlements.affirmInstruction(
58-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
59-
(transferToHolderTx as any).instruction,
60-
{
61-
options: { processMode: ProcessMode.Submit, signer: holder.signer },
62-
}
63-
);
64-
65-
expect(txData).toMatchObject({
66-
transactions: expect.arrayContaining([
67-
{
68-
transactionTag: 'settlement.affirmInstructionWithCount',
69-
type: 'single',
70-
...expectBasicTxInfo,
71-
},
72-
]),
73-
});
74-
75-
const { results } = await restClient.assets.getAssetHolders(assetId);
76-
77-
expect(results.length).toEqual(2);
78-
expect(results).toContainEqual(expect.objectContaining({
79-
identity: issuer.did,
80-
balance: '99990',
81-
}));
82-
expect(results).toContainEqual(expect.objectContaining({
83-
identity: holder.did,
84-
balance: '10',
85-
}));
48+
});
49+
50+
it('should transfer the asset to holder', async () => {
51+
const transferToHolderTx = await restClient.settlements.createDirectInstruction(
52+
fungibleInstructionParams(assetId, issuer.did, holder.did, {
53+
options: { processMode: ProcessMode.Submit, signer },
54+
})
55+
);
56+
57+
// should have created an instruction
58+
expect((transferToHolderTx as RestSuccessResult).instruction).toBeDefined();
59+
60+
const txData = await restClient.settlements.affirmInstruction(
61+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
62+
(transferToHolderTx as any).instruction,
63+
{
64+
options: { processMode: ProcessMode.Submit, signer: holder.signer },
65+
}
66+
);
67+
68+
expect(txData).toMatchObject({
69+
transactions: expect.arrayContaining([
70+
{
71+
transactionTag: 'settlement.affirmInstructionWithCount',
72+
type: 'single',
73+
...expectBasicTxInfo,
74+
},
75+
]),
8676
});
8777

88-
it('should run controller transfer and return the asset back to the issuer', async () => {
89-
const controllerTransferTx = await restClient.assets.controllerTransfer(assetId, controllerTransferParams({ did: holder.did, id: '0' }, 10, {
90-
options: { processMode: ProcessMode.Submit, signer },
91-
})) as RestSuccessResult;
92-
93-
expect(controllerTransferTx).toMatchObject({
94-
transactions: expect.arrayContaining([
95-
{
96-
transactionTag: 'asset.controllerTransfer',
97-
type: 'single',
98-
...expectBasicTxInfo,
99-
},
100-
]),
101-
});
102-
103-
104-
const { results } = await restClient.assets.getAssetHolders(assetId);
105-
106-
expect(results.length).toEqual(1);
107-
expect(results).toContainEqual(expect.objectContaining({
108-
identity: expect.objectContaining({
109-
did: issuer.did,
110-
}),
111-
balance: expect.objectContaining({
112-
amount: '100000',
113-
}),
114-
}));
78+
const { results } = await restClient.assets.getAssetHolders(assetId);
79+
80+
expect(results.length).toEqual(2);
81+
expect(results).toContainEqual(
82+
expect.objectContaining({
83+
identity: issuer.did,
84+
balance: '99990',
85+
})
86+
);
87+
expect(results).toContainEqual(
88+
expect.objectContaining({
89+
identity: holder.did,
90+
balance: '10',
91+
})
92+
);
93+
});
94+
95+
it('should run controller transfer and return the asset back to the issuer', async () => {
96+
const controllerTransferTx = (await restClient.assets.controllerTransfer(
97+
assetId,
98+
controllerTransferParams({ did: holder.did, id: '0' }, 10, {
99+
options: { processMode: ProcessMode.Submit, signer },
100+
})
101+
)) as RestSuccessResult;
102+
103+
expect(controllerTransferTx).toMatchObject({
104+
transactions: expect.arrayContaining([
105+
{
106+
transactionTag: 'asset.controllerTransfer',
107+
type: 'single',
108+
...expectBasicTxInfo,
109+
},
110+
]),
115111
});
112+
113+
const { results } = await restClient.assets.getAssetHolders(assetId);
114+
115+
expect(results.length).toBeGreaterThan(1);
116+
expect(results).toEqual(
117+
expect.arrayContaining([
118+
{
119+
identity: issuer.did,
120+
balance: '100000',
121+
},
122+
])
123+
);
124+
});
116125
});

‎tests/src/__tests__/sdk/assets/controllerTransfer.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ describe('controllerTransfer', () => {
1212
let sdk: Polymesh;
1313
let targetDid: string;
1414

15-
1615
beforeAll(async () => {
1716
factory = await TestFactory.create({});
1817
sdk = factory.polymeshSdk;
@@ -25,7 +24,6 @@ describe('controllerTransfer', () => {
2524
({
2625
results: [{ did: targetDid }],
2726
} = await factory.createIdentityForAddresses([targetAddress]));
28-
2927
});
3028

3129
afterAll(async () => {

‎tests/src/__tests__/sdk/assets/venueFiltering.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ describe('venueFiltering', () => {
1313
let sdk: Polymesh;
1414
let targetDid: string;
1515

16-
1716
beforeAll(async () => {
1817
factory = await TestFactory.create({});
1918
sdk = factory.polymeshSdk;

‎tests/src/rest/assets/client.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
assetMediatorsParams,
3+
controllerTransferParams,
34
createAssetParams,
45
createMetadataParams,
56
issueAssetParams,
@@ -8,11 +9,10 @@ import {
89
setAssetDocumentParams,
910
setMetadataParams,
1011
transferAssetOwnershipParams,
11-
controllerTransferParams,
1212
} from '~/rest/assets/params';
1313
import { RestClient } from '~/rest/client';
1414
import { TxBase } from '~/rest/common';
15-
import { PostResult, ResultSet, RestSuccessResult } from '~/rest/interfaces';
15+
import { PostResult, RestSuccessResult, ResultSet } from '~/rest/interfaces';
1616

1717
export class Assets {
1818
constructor(private client: RestClient) {}
@@ -135,7 +135,10 @@ export class Assets {
135135
return this.client.post(`assets/${asset}/unfreeze`, { ...params });
136136
}
137137

138-
public async controllerTransfer(asset: string, params: ReturnType<typeof controllerTransferParams>): Promise<PostResult> {
138+
public async controllerTransfer(
139+
asset: string,
140+
params: ReturnType<typeof controllerTransferParams>
141+
): Promise<PostResult> {
139142
return this.client.post(`assets/${asset}/controller-transfer`, params);
140143
}
141144

‎tests/src/rest/assets/params.ts‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,15 @@ export const issueAssetParams = (amount: number, base: TxBase, extras: TxExtras
106106
...base,
107107
} as const);
108108

109-
110-
export const controllerTransferParams = (origin: { did: string, id: string }, amount: number, base: TxBase, extras: TxExtras = {}) =>
109+
export const controllerTransferParams = (
110+
origin: { did: string; id: string },
111+
amount: number,
112+
base: TxBase,
113+
extras: TxExtras = {}
114+
) =>
111115
({
112116
origin,
113117
amount,
114118
...extras,
115119
...base,
116-
} as const);
120+
} as const);

0 commit comments

Comments
 (0)