@interest-protocol/vortex-sdk 7.1.0 → 7.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +163 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +162 -1
- package/dist/index.mjs.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/validate.d.ts +3 -0
- package/dist/utils/validate.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/utils/index.ts +1 -0
- package/src/utils/validate.ts +228 -0
package/dist/utils/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAKnD,MAAM,MAAM,UAAU,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;AAE5C,wBAAgB,aAAa,CAC3B,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,IAAI,GAAG,IAAI,GAChB,UAAU,CAkEZ;AAED,UAAU,gBAAgB;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,UAAU,CAAC;IACxB,WAAW,EAAE,UAAU,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,aAAa,CAAC;IAC7B,UAAU,EAAE,IAAI,CAAC;IACjB,UAAU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I,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,YAAY,GAAI,qMAgB1B,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;CAiClB,CAAC;AAQF,eAAO,MAAM,eAAe,GAAI,MAAM,aAAa;;;;;;;CAelD,CAAC;AAEF,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/utils/validate.ts"],"names":[],"mappings":"AA6NA,wBAAgB,kCAAkC,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAE3E;AAED,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAEjE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@interest-protocol/vortex-sdk",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.2.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"rimraf": "^6.0.1",
|
|
38
38
|
"ts-jest": "^29.1.1",
|
|
39
39
|
"tsup": "^8.3.5",
|
|
40
|
-
"@interest-protocol/
|
|
41
|
-
"@interest-protocol/
|
|
40
|
+
"@interest-protocol/typescript-config": "1.0.0",
|
|
41
|
+
"@interest-protocol/prettier-config": "1.0.0"
|
|
42
42
|
},
|
|
43
43
|
"publishConfig": {
|
|
44
44
|
"access": "public",
|
package/src/utils/index.ts
CHANGED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { normalizeSuiAddress, SUI_FRAMEWORK_ADDRESS } from '@mysten/sui/utils';
|
|
2
|
+
import invariant from 'tiny-invariant';
|
|
3
|
+
import { VORTEX_PACKAGE_ID } from '../constants';
|
|
4
|
+
|
|
5
|
+
interface MoveCall {
|
|
6
|
+
package: string;
|
|
7
|
+
module: string;
|
|
8
|
+
function: string;
|
|
9
|
+
typeArguments: string[];
|
|
10
|
+
arguments: object[];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface ExpectedCommand {
|
|
14
|
+
MoveCall?: {
|
|
15
|
+
package: string;
|
|
16
|
+
module: string;
|
|
17
|
+
function: string;
|
|
18
|
+
arguments: object[];
|
|
19
|
+
};
|
|
20
|
+
MakeMoveVec?: {
|
|
21
|
+
elements: object[];
|
|
22
|
+
};
|
|
23
|
+
TransferObjects?: {
|
|
24
|
+
objects: object[];
|
|
25
|
+
address: object;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const EXPECTED_DEPOSIT_WITH_ACCOUNT_COMMANDS: ExpectedCommand[] = [
|
|
30
|
+
{
|
|
31
|
+
MoveCall: {
|
|
32
|
+
package: VORTEX_PACKAGE_ID,
|
|
33
|
+
module: 'vortex_ext_data',
|
|
34
|
+
function: 'new',
|
|
35
|
+
arguments: [
|
|
36
|
+
{ Input: 0 },
|
|
37
|
+
{ Input: 1 },
|
|
38
|
+
{ Input: 2 },
|
|
39
|
+
{ Input: 3 },
|
|
40
|
+
{ Input: 4 },
|
|
41
|
+
{ Input: 5 },
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
MoveCall: {
|
|
47
|
+
package: VORTEX_PACKAGE_ID,
|
|
48
|
+
module: 'vortex_proof',
|
|
49
|
+
function: 'new',
|
|
50
|
+
arguments: [
|
|
51
|
+
{ Input: 6 },
|
|
52
|
+
{ Input: 7 },
|
|
53
|
+
{ Input: 8 },
|
|
54
|
+
{ Input: 9 },
|
|
55
|
+
{ Input: 10 },
|
|
56
|
+
{ Input: 11 },
|
|
57
|
+
{ Input: 12 },
|
|
58
|
+
{ Input: 13 },
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
MakeMoveVec: {
|
|
64
|
+
elements: [{ Input: 16 }],
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
MoveCall: {
|
|
69
|
+
package: VORTEX_PACKAGE_ID,
|
|
70
|
+
module: 'vortex',
|
|
71
|
+
function: 'transact_with_account',
|
|
72
|
+
arguments: [
|
|
73
|
+
{ Input: 14 },
|
|
74
|
+
{ Input: 15 },
|
|
75
|
+
{ Result: 2 },
|
|
76
|
+
{ Result: 1 },
|
|
77
|
+
{ Result: 0 },
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
TransferObjects: {
|
|
83
|
+
objects: [{ Result: 3 }],
|
|
84
|
+
address: { Input: 17 },
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
];
|
|
88
|
+
|
|
89
|
+
const EXPECTED_WITHDRAW_COMMANDS: ExpectedCommand[] = [
|
|
90
|
+
{
|
|
91
|
+
MoveCall: {
|
|
92
|
+
package: VORTEX_PACKAGE_ID,
|
|
93
|
+
module: 'vortex_ext_data',
|
|
94
|
+
function: 'new',
|
|
95
|
+
arguments: [
|
|
96
|
+
{ Input: 0 },
|
|
97
|
+
{ Input: 1 },
|
|
98
|
+
{ Input: 2 },
|
|
99
|
+
{ Input: 3 },
|
|
100
|
+
{ Input: 4 },
|
|
101
|
+
{ Input: 5 },
|
|
102
|
+
],
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
MoveCall: {
|
|
107
|
+
package: VORTEX_PACKAGE_ID,
|
|
108
|
+
module: 'vortex_proof',
|
|
109
|
+
function: 'new',
|
|
110
|
+
arguments: [
|
|
111
|
+
{ Input: 6 },
|
|
112
|
+
{ Input: 7 },
|
|
113
|
+
{ Input: 8 },
|
|
114
|
+
{ Input: 9 },
|
|
115
|
+
{ Input: 10 },
|
|
116
|
+
{ Input: 11 },
|
|
117
|
+
{ Input: 12 },
|
|
118
|
+
{ Input: 13 },
|
|
119
|
+
],
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
MoveCall: {
|
|
124
|
+
package: SUI_FRAMEWORK_ADDRESS,
|
|
125
|
+
module: 'coin',
|
|
126
|
+
function: 'zero',
|
|
127
|
+
arguments: [],
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
MoveCall: {
|
|
132
|
+
package: VORTEX_PACKAGE_ID,
|
|
133
|
+
module: 'vortex',
|
|
134
|
+
function: 'transact',
|
|
135
|
+
arguments: [
|
|
136
|
+
{ Input: 14 },
|
|
137
|
+
{ Result: 2 },
|
|
138
|
+
{ Result: 1 },
|
|
139
|
+
{ Result: 0 },
|
|
140
|
+
],
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
TransferObjects: {
|
|
145
|
+
objects: [{ Result: 3 }],
|
|
146
|
+
address: { Input: 15 },
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
];
|
|
150
|
+
|
|
151
|
+
function validateCommands(
|
|
152
|
+
commands: object[],
|
|
153
|
+
expectedCommands: ExpectedCommand[]
|
|
154
|
+
): void {
|
|
155
|
+
invariant(
|
|
156
|
+
commands.length === expectedCommands.length,
|
|
157
|
+
`Expected ${expectedCommands.length} commands, got ${commands.length}`
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
for (let i = 0; i < commands.length; i++) {
|
|
161
|
+
const actual = commands[i] as Record<string, unknown>;
|
|
162
|
+
const expected = expectedCommands[i]!;
|
|
163
|
+
|
|
164
|
+
if ('MoveCall' in expected && expected.MoveCall) {
|
|
165
|
+
invariant('MoveCall' in actual, `Command ${i}: Expected MoveCall`);
|
|
166
|
+
const actualMoveCall = actual.MoveCall as MoveCall;
|
|
167
|
+
const expectedMoveCall = expected.MoveCall;
|
|
168
|
+
|
|
169
|
+
invariant(
|
|
170
|
+
normalizeSuiAddress(actualMoveCall.package) ===
|
|
171
|
+
normalizeSuiAddress(expectedMoveCall.package),
|
|
172
|
+
`Command ${i}: Package mismatch. Expected ${expectedMoveCall.package}, got ${actualMoveCall.package}`
|
|
173
|
+
);
|
|
174
|
+
invariant(
|
|
175
|
+
actualMoveCall.module === expectedMoveCall.module,
|
|
176
|
+
`Command ${i}: Module mismatch. Expected ${expectedMoveCall.module}, got ${actualMoveCall.module}`
|
|
177
|
+
);
|
|
178
|
+
invariant(
|
|
179
|
+
actualMoveCall.function === expectedMoveCall.function,
|
|
180
|
+
`Command ${i}: Function mismatch. Expected ${expectedMoveCall.function}, got ${actualMoveCall.function}`
|
|
181
|
+
);
|
|
182
|
+
invariant(
|
|
183
|
+
JSON.stringify(actualMoveCall.arguments) ===
|
|
184
|
+
JSON.stringify(expectedMoveCall.arguments),
|
|
185
|
+
`Command ${i}: Arguments mismatch`
|
|
186
|
+
);
|
|
187
|
+
} else if ('MakeMoveVec' in expected && expected.MakeMoveVec) {
|
|
188
|
+
invariant('MakeMoveVec' in actual, `Command ${i}: Expected MakeMoveVec`);
|
|
189
|
+
const actualMakeMoveVec = actual.MakeMoveVec as { elements: object[] };
|
|
190
|
+
const expectedMakeMoveVec = expected.MakeMoveVec;
|
|
191
|
+
|
|
192
|
+
invariant(
|
|
193
|
+
JSON.stringify(actualMakeMoveVec.elements) ===
|
|
194
|
+
JSON.stringify(expectedMakeMoveVec.elements),
|
|
195
|
+
`Command ${i}: MakeMoveVec elements mismatch`
|
|
196
|
+
);
|
|
197
|
+
} else if ('TransferObjects' in expected && expected.TransferObjects) {
|
|
198
|
+
invariant(
|
|
199
|
+
'TransferObjects' in actual,
|
|
200
|
+
`Command ${i}: Expected TransferObjects`
|
|
201
|
+
);
|
|
202
|
+
const actualTransfer = actual.TransferObjects as {
|
|
203
|
+
objects: object[];
|
|
204
|
+
address: object;
|
|
205
|
+
};
|
|
206
|
+
const expectedTransfer = expected.TransferObjects;
|
|
207
|
+
|
|
208
|
+
invariant(
|
|
209
|
+
JSON.stringify(actualTransfer.objects) ===
|
|
210
|
+
JSON.stringify(expectedTransfer.objects),
|
|
211
|
+
`Command ${i}: TransferObjects objects mismatch`
|
|
212
|
+
);
|
|
213
|
+
invariant(
|
|
214
|
+
JSON.stringify(actualTransfer.address) ===
|
|
215
|
+
JSON.stringify(expectedTransfer.address),
|
|
216
|
+
`Command ${i}: TransferObjects address mismatch`
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export function validateDepositWithAccountCommands(commands: object[]): void {
|
|
223
|
+
validateCommands(commands, EXPECTED_DEPOSIT_WITH_ACCOUNT_COMMANDS);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export function validateWithdrawCommands(commands: object[]): void {
|
|
227
|
+
validateCommands(commands, EXPECTED_WITHDRAW_COMMANDS);
|
|
228
|
+
}
|