@thalalabs/surf 1.7.0 → 1.7.1
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/CHANGELOG.md +6 -0
- package/build/cjs/core/Client.js +7 -4
- package/build/cjs/core/Client.js.map +1 -1
- package/build/esm/core/Client.js +7 -4
- package/build/esm/core/Client.js.map +1 -1
- package/build/types/core/Client.d.ts +1 -1
- package/build/types/core/Client.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/Client.ts +61 -42
package/CHANGELOG.md
CHANGED
package/build/cjs/core/Client.js
CHANGED
|
@@ -45,7 +45,10 @@ class Client {
|
|
|
45
45
|
}))[0];
|
|
46
46
|
}
|
|
47
47
|
async fetchABI(address, moduleName) {
|
|
48
|
-
return (await this.client.getAccountModule({
|
|
48
|
+
return (await this.client.getAccountModule({
|
|
49
|
+
accountAddress: address,
|
|
50
|
+
moduleName: moduleName,
|
|
51
|
+
})).abi;
|
|
49
52
|
}
|
|
50
53
|
useABI(abi, address) {
|
|
51
54
|
return {
|
|
@@ -63,7 +66,7 @@ class Client {
|
|
|
63
66
|
payload,
|
|
64
67
|
options: {
|
|
65
68
|
ledgerVersion: args[0].ledgerVersion,
|
|
66
|
-
}
|
|
69
|
+
},
|
|
67
70
|
});
|
|
68
71
|
};
|
|
69
72
|
},
|
|
@@ -102,10 +105,10 @@ class Client {
|
|
|
102
105
|
const account = args[0].account;
|
|
103
106
|
return this.client.getAccountResource({
|
|
104
107
|
accountAddress: account,
|
|
105
|
-
resourceType: `${abi.address}::${abi.name}::${structName}`,
|
|
108
|
+
resourceType: `${address ?? abi.address}::${abi.name}::${structName}`,
|
|
106
109
|
options: {
|
|
107
110
|
ledgerVersion: args[0].ledgerVersion,
|
|
108
|
-
}
|
|
111
|
+
},
|
|
109
112
|
});
|
|
110
113
|
};
|
|
111
114
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Client.js","sourceRoot":"","sources":["../../../src/core/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C,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;yBACtD;wBAED,MAAM,OAAO,GAAwB,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;wBACrD,OAAO,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC;4BACpC,cAAc,EAAE,OAAO;4BACvB,YAAY,EAAE,GAAG,OAAO,IAAI,GAAG,CAAC,OAAO,KAAK,GAAG,CAAC,IAAI,KAAK,UAAU,EAAE;4BACrE,OAAO,EAAE;gCACP,aAAa,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,aAAa;6BACrC;yBACF,CAAC,CAAC;oBACL,CAAC,CAAC;gBACJ,CAAC;aACF,CAAC;SACH,CAAC;IACJ,CAAC;CACF;AAlPD,wBAkPC"}
|
package/build/esm/core/Client.js
CHANGED
|
@@ -41,7 +41,10 @@ export class Client {
|
|
|
41
41
|
}))[0];
|
|
42
42
|
}
|
|
43
43
|
async fetchABI(address, moduleName) {
|
|
44
|
-
return (await this.client.getAccountModule({
|
|
44
|
+
return (await this.client.getAccountModule({
|
|
45
|
+
accountAddress: address,
|
|
46
|
+
moduleName: moduleName,
|
|
47
|
+
})).abi;
|
|
45
48
|
}
|
|
46
49
|
useABI(abi, address) {
|
|
47
50
|
return {
|
|
@@ -59,7 +62,7 @@ export class Client {
|
|
|
59
62
|
payload,
|
|
60
63
|
options: {
|
|
61
64
|
ledgerVersion: args[0].ledgerVersion,
|
|
62
|
-
}
|
|
65
|
+
},
|
|
63
66
|
});
|
|
64
67
|
};
|
|
65
68
|
},
|
|
@@ -98,10 +101,10 @@ export class Client {
|
|
|
98
101
|
const account = args[0].account;
|
|
99
102
|
return this.client.getAccountResource({
|
|
100
103
|
accountAddress: account,
|
|
101
|
-
resourceType: `${abi.address}::${abi.name}::${structName}`,
|
|
104
|
+
resourceType: `${address ?? abi.address}::${abi.name}::${structName}`,
|
|
102
105
|
options: {
|
|
103
106
|
ledgerVersion: args[0].ledgerVersion,
|
|
104
|
-
}
|
|
107
|
+
},
|
|
105
108
|
});
|
|
106
109
|
};
|
|
107
110
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Client.js","sourceRoot":"","sources":["../../../src/core/Client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"Client.js","sourceRoot":"","sources":["../../../src/core/Client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AA+B7D,MAAM,UAAU,gBAAgB,CAC9B,WAAkB;IAElB,OAAO,IAAI,MAAM,CAAY,WAAW,CAAC,CAAC;AAC5C,CAAC;AACD,MAAM,OAAO,MAAM;IAGjB,YAAY,MAAa;QAFjB;;;;;WAAc;QAGpB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAgBM,KAAK,CAAC,IAAI,CAA8B,IAG9C;QACC,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IAqBM,KAAK,CAAC,iBAAiB,CAAC,IAI9B;QACC,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC;YAC7D,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE;YAC7C,IAAI,EAAE,IAAI,CAAC,OAAO;SACnB,CAAC,CAAC;QAGH,MAAM,cAAc,GAClB,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,wBAAwB,CAAC;YACrD,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,WAAW;SACZ,CAAC,CAAC;QAIL,OAAO,MAAM,IAAI,CAAC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;gBACzD,GAAG,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE;oBACf,IAAI,UAAU,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;oBACjC,OAAO,CAAC,GAAG,IAAI,EAAE,EAAE;wBACjB,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE;4BACtC,UAAU,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;yBACtD;wBAED,MAAM,OAAO,GAAwB,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;wBACrD,OAAO,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC;4BACpC,cAAc,EAAE,OAAO;4BACvB,YAAY,EAAE,GAAG,OAAO,IAAI,GAAG,CAAC,OAAO,KAAK,GAAG,CAAC,IAAI,KAAK,UAAU,EAAE;4BACrE,OAAO,EAAE;gCACP,aAAa,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,aAAa;6BACrC;yBACF,CAAC,CAAC;oBACL,CAAC,CAAC;gBACJ,CAAC;aACF,CAAC;SACH,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ABIEntryClient, ABIViewClient, ABIRoot, EntryPayload, ViewPayload, DefaultABITable, ABIResourceClient } from '../types/index.js';
|
|
2
2
|
import { ABITable } from '../types/defaultABITable.js';
|
|
3
|
-
import { Aptos, LedgerVersionArg, MoveValue, Account, CommittedTransactionResponse, PublicKey, AccountAddressInput, UserTransactionResponse, WaitForTransactionOptions } from
|
|
3
|
+
import { Aptos, LedgerVersionArg, MoveValue, Account, CommittedTransactionResponse, PublicKey, AccountAddressInput, UserTransactionResponse, WaitForTransactionOptions } from '@aptos-labs/ts-sdk';
|
|
4
4
|
/**
|
|
5
5
|
* Create a client to interact with Aptos smart contract.
|
|
6
6
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Client.d.ts","sourceRoot":"","sources":["../../../src/core/Client.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,cAAc,EACd,aAAa,EACb,OAAO,EACP,YAAY,EACZ,WAAW,EACX,eAAe,EACf,iBAAiB,EAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,
|
|
1
|
+
{"version":3,"file":"Client.d.ts","sourceRoot":"","sources":["../../../src/core/Client.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,cAAc,EACd,aAAa,EACb,OAAO,EACP,YAAY,EACZ,WAAW,EACX,eAAe,EACf,iBAAiB,EAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EACL,KAAK,EACL,gBAAgB,EAChB,SAAS,EACT,OAAO,EACP,4BAA4B,EAC5B,SAAS,EACT,mBAAmB,EACnB,uBAAuB,EACvB,yBAAyB,EAC1B,MAAM,oBAAoB,CAAC;AAE5B;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,SAAS,QAAQ,GAAG,eAAe,EAC3E,WAAW,EAAE,KAAK,GACjB,MAAM,CAAC,SAAS,CAAC,CAEnB;AACD,qBAAa,MAAM,CAAC,SAAS,SAAS,QAAQ;IAC5C,OAAO,CAAC,MAAM,CAAQ;gBAEV,MAAM,EAAE,KAAK;IAIzB;;;;;;;;;;;;;OAaG;IACU,IAAI,CAAC,OAAO,SAAS,SAAS,EAAE,EAAE,IAAI,EAAE;QACnD,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;QAC9B,OAAO,CAAC,EAAE,gBAAgB,CAAC;KAC5B,GAAG,OAAO,CAAC,OAAO,CAAC;IAIpB;;;;;;;;;;;;;;;;;;OAkBG;IACU,iBAAiB,CAAC,IAAI,EAAE;QACnC,MAAM,EAAE,OAAO,CAAC;QAChB,OAAO,EAAE,YAAY,CAAC;QACtB,OAAO,CAAC,EAAE,yBAAyB,CAAC;KACrC,GAAG,OAAO,CAAC,4BAA4B,CAAC;IAqBzC;;;;;;;;;;;;;;;;;;;OAmBG;IACU,mBAAmB,CAAC,IAAI,EAAE;QACrC,SAAS,EAAE,SAAS,CAAC;QACrB,MAAM,EAAE,mBAAmB,CAAC;QAC5B,OAAO,EAAE,YAAY,CAAC;KACvB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAcpC;;;;;;;;OAQG;IACU,QAAQ,CAAC,CAAC,SAAS,OAAO,EACrC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,CAAC,CAAC;IAWb;;;;;;;;;;;OAWG;IACI,MAAM,CAAC,CAAC,SAAS,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM;QAErD;;;;;;;;WAQG;;QAqBH;;;;;;;;;WASG;;QA2BH;;;;;;;;WAQG;;;CAsBR"}
|
package/package.json
CHANGED
package/src/core/Client.ts
CHANGED
|
@@ -7,10 +7,20 @@ import {
|
|
|
7
7
|
EntryPayload,
|
|
8
8
|
ViewPayload,
|
|
9
9
|
DefaultABITable,
|
|
10
|
-
ABIResourceClient
|
|
10
|
+
ABIResourceClient,
|
|
11
11
|
} from '../types/index.js';
|
|
12
12
|
import { ABITable } from '../types/defaultABITable.js';
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
Aptos,
|
|
15
|
+
LedgerVersionArg,
|
|
16
|
+
MoveValue,
|
|
17
|
+
Account,
|
|
18
|
+
CommittedTransactionResponse,
|
|
19
|
+
PublicKey,
|
|
20
|
+
AccountAddressInput,
|
|
21
|
+
UserTransactionResponse,
|
|
22
|
+
WaitForTransactionOptions,
|
|
23
|
+
} from '@aptos-labs/ts-sdk';
|
|
14
24
|
|
|
15
25
|
/**
|
|
16
26
|
* Create a client to interact with Aptos smart contract.
|
|
@@ -20,9 +30,9 @@ import { Aptos, LedgerVersionArg, MoveValue, Account, CommittedTransactionRespon
|
|
|
20
30
|
* @example
|
|
21
31
|
* const client = createSurfClient(new Aptos());
|
|
22
32
|
*/
|
|
23
|
-
export function createSurfClient<
|
|
24
|
-
|
|
25
|
-
|
|
33
|
+
export function createSurfClient<TABITable extends ABITable = DefaultABITable>(
|
|
34
|
+
aptosClient: Aptos,
|
|
35
|
+
): Client<TABITable> {
|
|
26
36
|
return new Client<TABITable>(aptosClient);
|
|
27
37
|
}
|
|
28
38
|
export class Client<TABITable extends ABITable> {
|
|
@@ -47,7 +57,7 @@ export class Client<TABITable extends ABITable> {
|
|
|
47
57
|
* const [balance] = await client.view({ payload });
|
|
48
58
|
*/
|
|
49
59
|
public async view<TReturn extends MoveValue[]>(args: {
|
|
50
|
-
payload: ViewPayload<TReturn
|
|
60
|
+
payload: ViewPayload<TReturn>;
|
|
51
61
|
options?: LedgerVersionArg;
|
|
52
62
|
}): Promise<TReturn> {
|
|
53
63
|
return await this.client.view(args);
|
|
@@ -73,9 +83,9 @@ export class Client<TABITable extends ABITable> {
|
|
|
73
83
|
* });
|
|
74
84
|
*/
|
|
75
85
|
public async submitTransaction(args: {
|
|
76
|
-
signer: Account
|
|
77
|
-
payload: EntryPayload
|
|
78
|
-
options?: WaitForTransactionOptions
|
|
86
|
+
signer: Account;
|
|
87
|
+
payload: EntryPayload;
|
|
88
|
+
options?: WaitForTransactionOptions;
|
|
79
89
|
}): Promise<CommittedTransactionResponse> {
|
|
80
90
|
const transaction = await this.client.transaction.build.simple({
|
|
81
91
|
sender: args.signer.accountAddress.toString(),
|
|
@@ -83,10 +93,11 @@ export class Client<TABITable extends ABITable> {
|
|
|
83
93
|
});
|
|
84
94
|
|
|
85
95
|
// Submit the transaction
|
|
86
|
-
const transactionRes =
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
96
|
+
const transactionRes =
|
|
97
|
+
await this.client.transaction.signAndSubmitTransaction({
|
|
98
|
+
signer: args.signer,
|
|
99
|
+
transaction,
|
|
100
|
+
});
|
|
90
101
|
|
|
91
102
|
// Wait for the transaction to finish
|
|
92
103
|
// throws an error if the tx fails or not confirmed after timeout
|
|
@@ -117,34 +128,44 @@ export class Client<TABITable extends ABITable> {
|
|
|
117
128
|
* });
|
|
118
129
|
*/
|
|
119
130
|
public async simulateTransaction(args: {
|
|
120
|
-
publicKey: PublicKey
|
|
121
|
-
sender: AccountAddressInput
|
|
122
|
-
payload: EntryPayload
|
|
131
|
+
publicKey: PublicKey;
|
|
132
|
+
sender: AccountAddressInput;
|
|
133
|
+
payload: EntryPayload;
|
|
123
134
|
}): Promise<UserTransactionResponse> {
|
|
124
135
|
const transaction = await this.client.transaction.build.simple({
|
|
125
136
|
sender: args.sender,
|
|
126
137
|
data: args.payload,
|
|
127
138
|
});
|
|
128
139
|
|
|
129
|
-
return (
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
140
|
+
return (
|
|
141
|
+
await this.client.transaction.simulate.simple({
|
|
142
|
+
signerPublicKey: args.publicKey,
|
|
143
|
+
transaction,
|
|
144
|
+
})
|
|
145
|
+
)[0]!;
|
|
133
146
|
}
|
|
134
147
|
|
|
135
148
|
/**
|
|
136
149
|
* Builds ABI from a provided address and module name for given client. ABI name can be taken from abi.name
|
|
137
|
-
*
|
|
150
|
+
*
|
|
138
151
|
* @param address The module address
|
|
139
152
|
* @param moduleName The module name
|
|
140
153
|
* @returns The constructed ABI
|
|
141
154
|
* @example
|
|
142
155
|
* const abi = await client.fetchABI(address = '0x1', moduleName = 'AptosCoin');
|
|
143
156
|
*/
|
|
144
|
-
public async fetchABI<T extends ABIRoot>(
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
157
|
+
public async fetchABI<T extends ABIRoot>(
|
|
158
|
+
address: string,
|
|
159
|
+
moduleName: string,
|
|
160
|
+
): Promise<T> {
|
|
161
|
+
// Fetches ABI fom address and module name for given client
|
|
162
|
+
// throws if inexistent module name in address for given client
|
|
163
|
+
return (
|
|
164
|
+
await this.client.getAccountModule({
|
|
165
|
+
accountAddress: address,
|
|
166
|
+
moduleName: moduleName,
|
|
167
|
+
})
|
|
168
|
+
).abi as unknown as T;
|
|
148
169
|
}
|
|
149
170
|
|
|
150
171
|
/**
|
|
@@ -184,7 +205,7 @@ export class Client<TABITable extends ABITable> {
|
|
|
184
205
|
payload,
|
|
185
206
|
options: {
|
|
186
207
|
ledgerVersion: args[0].ledgerVersion,
|
|
187
|
-
}
|
|
208
|
+
},
|
|
188
209
|
});
|
|
189
210
|
};
|
|
190
211
|
},
|
|
@@ -214,14 +235,14 @@ export class Client<TABITable extends ABITable> {
|
|
|
214
235
|
const account: Account = args[0].account;
|
|
215
236
|
return args[0].isSimulation
|
|
216
237
|
? this.simulateTransaction({
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
238
|
+
publicKey: account.publicKey,
|
|
239
|
+
sender: account.accountAddress.toString(),
|
|
240
|
+
payload,
|
|
241
|
+
})
|
|
221
242
|
: this.submitTransaction({
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
243
|
+
signer: args[0].account,
|
|
244
|
+
payload,
|
|
245
|
+
});
|
|
225
246
|
};
|
|
226
247
|
},
|
|
227
248
|
}),
|
|
@@ -244,15 +265,13 @@ export class Client<TABITable extends ABITable> {
|
|
|
244
265
|
}
|
|
245
266
|
|
|
246
267
|
const account: AccountAddressInput = args[0].account;
|
|
247
|
-
return this.client.getAccountResource(
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
}
|
|
255
|
-
);
|
|
268
|
+
return this.client.getAccountResource({
|
|
269
|
+
accountAddress: account,
|
|
270
|
+
resourceType: `${address ?? abi.address}::${abi.name}::${structName}`,
|
|
271
|
+
options: {
|
|
272
|
+
ledgerVersion: args[0].ledgerVersion,
|
|
273
|
+
},
|
|
274
|
+
});
|
|
256
275
|
};
|
|
257
276
|
},
|
|
258
277
|
}),
|