@thalalabs/surf 1.6.1 → 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 +13 -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/build/types/types/abi.d.ts +1 -1
- package/build/types/types/abi.d.ts.map +1 -1
- package/build/types/types/convertor/argsConvertor.d.ts +1 -1
- package/build/types/types/convertor/argsConvertor.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/Client.ts +61 -42
- package/src/core/__tests__/option.test.ts +42 -34
- package/src/core/__tests__/useABI.test.ts +10 -1
- package/src/types/abi.ts +1 -1
- package/src/types/convertor/argsConvertor.ts +24 -24
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @thalalabs/surf
|
|
2
2
|
|
|
3
|
+
## 1.7.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- df5280a: Fix failed to override resource abi address
|
|
8
|
+
|
|
9
|
+
## 1.7.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 8fad9b9: add "private" in ABI visibility field
|
|
14
|
+
- 8fad9b9: Fix Aptos Move optional type
|
|
15
|
+
|
|
3
16
|
## 1.6.1
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
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/Client.ts"],"names":[],"mappings":";;;AAAA,iEAA2D;AAC3D,mEAA6D;
|
|
1
|
+
{"version":3,"file":"Client.js","sourceRoot":"","sources":["../../../src/core/Client.ts"],"names":[],"mappings":";;;AAAA,iEAA2D;AAC3D,mEAA6D;AA+B7D,SAAgB,gBAAgB,CAC9B,WAAkB;IAElB,OAAO,IAAI,MAAM,CAAY,WAAW,CAAC,CAAC;AAC5C,CAAC;AAJD,4CAIC;AACD,MAAa,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,CA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chABI(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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,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,E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;;;WAQG;;;CAsBR"}
|
|
@@ -10,7 +10,7 @@ export interface ABIRoot {
|
|
|
10
10
|
}
|
|
11
11
|
export interface ABIFunction {
|
|
12
12
|
name: string;
|
|
13
|
-
visibility: 'friend' | 'public';
|
|
13
|
+
visibility: 'friend' | 'public' | 'private';
|
|
14
14
|
is_entry: boolean;
|
|
15
15
|
is_view: boolean;
|
|
16
16
|
generic_type_params: readonly ABIFunctionGenericTypeParam[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abi.d.ts","sourceRoot":"","sources":["../../../src/types/abi.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,iBAAiB,EAAE,SAAS,WAAW,EAAE,CAAC;IAC1C,OAAO,EAAE,SAAS,SAAS,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,QAAQ,GAAG,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"abi.d.ts","sourceRoot":"","sources":["../../../src/types/abi.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,iBAAiB,EAAE,SAAS,WAAW,EAAE,CAAC;IAC1C,OAAO,EAAE,SAAS,SAAS,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;IAC5C,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,mBAAmB,EAAE,SAAS,2BAA2B,EAAE,CAAC;IAC5D,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,2BAA2B;IAE1C,WAAW,EAAE,SAAS,GAAG,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7B,mBAAmB,EAAE,SAAS,2BAA2B,EAAE,CAAC;IAC5D,MAAM,EAAE,SAAS,cAAc,EAAE,CAAC;CACnC;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd"}
|
|
@@ -16,6 +16,6 @@ export type ConvertArgs<T extends readonly string[]> = T extends readonly [
|
|
|
16
16
|
*/
|
|
17
17
|
type ConvertArgType<TMoveType extends string> = TMoveType extends MoveNonStructTypes ? ConvertNonStructArgType<TMoveType> : UnknownStruct<TMoveType>;
|
|
18
18
|
type ConvertPrimitiveArgType<TMoveType extends MovePrimitive> = TMoveType extends 'bool' ? boolean : TMoveType extends 'u8' ? number : TMoveType extends 'u16' ? number : TMoveType extends 'u32' ? number : TMoveType extends 'u64' ? AnyNumber : TMoveType extends 'u128' ? AnyNumber : TMoveType extends 'u256' ? AnyNumber : TMoveType extends 'address' ? `0x${string}` : TMoveType extends '0x1::string::String' ? string : never;
|
|
19
|
-
type ConvertNonStructArgType<TMoveType extends MoveNonStructTypes> = TMoveType extends MovePrimitive ? ConvertPrimitiveArgType<TMoveType> : TMoveType extends `vector<u8>` ? string | number[] | Uint8Array : TMoveType extends `vector<${infer TInner}>` ? ConvertArgType<TInner>[] : TMoveType extends `0x1::object::Object<${string}>` ? `0x${string}` : TMoveType extends `0x1::option::Option<${infer TInner}>` ? ConvertArgType<TInner> |
|
|
19
|
+
type ConvertNonStructArgType<TMoveType extends MoveNonStructTypes> = TMoveType extends MovePrimitive ? ConvertPrimitiveArgType<TMoveType> : TMoveType extends `vector<u8>` ? string | number[] | Uint8Array : TMoveType extends `vector<${infer TInner}>` ? ConvertArgType<TInner>[] : TMoveType extends `0x1::object::Object<${string}>` ? `0x${string}` : TMoveType extends `0x1::option::Option<${infer TInner}>` ? ConvertArgType<TInner> | undefined : UnknownStruct<TMoveType>;
|
|
20
20
|
export {};
|
|
21
21
|
//# sourceMappingURL=argsConvertor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"argsConvertor.d.ts","sourceRoot":"","sources":["../../../../src/types/convertor/argsConvertor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEpE;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,SAAS,MAAM,EAAE,IAAI,CAAC,SAAS,SAAS;IACxE,MAAM,IAAI,SAAS,MAAM;IACzB,GAAG,MAAM,KAAK,SAAS,MAAM,EAAE;CAChC,GACG,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,GAC7C,EAAE,CAAC;AAEP;;GAEG;AACH,KAAK,cAAc,CAAC,SAAS,SAAS,MAAM,IAC1C,SAAS,SAAS,kBAAkB,GAEhC,uBAAuB,CAAC,SAAS,CAAC,GAElC,aAAa,CAAC,SAAS,CAAC,CAAC;AAE/B,KAAK,uBAAuB,CAAC,SAAS,SAAS,aAAa,IAC1D,SAAS,SAAS,MAAM,GACpB,OAAO,GACP,SAAS,SAAS,IAAI,
|
|
1
|
+
{"version":3,"file":"argsConvertor.d.ts","sourceRoot":"","sources":["../../../../src/types/convertor/argsConvertor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAA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ACb,SAAS,SAAS,uBAAuB,MAAM,MAAM,GAAG,GACtD,cAAc,CAAC,MAAM,CAAC,GAAG,SAAS,GAClC,aAAa,CAAC,SAAS,CAAC,CAAC"}
|
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
|
}),
|
|
@@ -4,50 +4,58 @@
|
|
|
4
4
|
|
|
5
5
|
import { createSurfClient } from '../Client';
|
|
6
6
|
import { createEntryPayload } from '../createEntryPayload';
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
Account,
|
|
9
|
+
Aptos,
|
|
10
|
+
AptosConfig,
|
|
11
|
+
Ed25519PrivateKey,
|
|
12
|
+
Network,
|
|
13
|
+
} from '@aptos-labs/ts-sdk';
|
|
8
14
|
|
|
9
15
|
describe('option type', () => {
|
|
10
16
|
const client = createSurfClient(
|
|
11
|
-
new Aptos(
|
|
12
|
-
new AptosConfig({ network: Network.TESTNET })
|
|
13
|
-
)
|
|
17
|
+
new Aptos(new AptosConfig({ network: Network.TESTNET })),
|
|
14
18
|
);
|
|
15
19
|
|
|
16
|
-
const account = Account.fromPrivateKey({
|
|
20
|
+
const account = Account.fromPrivateKey({
|
|
21
|
+
privateKey: new Ed25519PrivateKey(
|
|
22
|
+
'0x4b0a52d0b047b6868d9650fdb9b61720e361ba74f40571635fec0694a838eb98',
|
|
23
|
+
),
|
|
24
|
+
});
|
|
17
25
|
|
|
18
26
|
// TODO: correctly encode option type for view function
|
|
19
|
-
// it('view function some value', async () => {
|
|
20
|
-
// const payload = createViewPayload(OPTION_ABI, {
|
|
21
|
-
// function: 'test_option_view',
|
|
22
|
-
// functionArguments: [{ vec: ['50'] } as any],
|
|
23
|
-
// typeArguments: [],
|
|
24
|
-
// });
|
|
25
|
-
// const result = await client.view({ payload });
|
|
26
|
-
// expect(result).toMatchInlineSnapshot(`
|
|
27
|
-
// [
|
|
28
|
-
// "50",
|
|
29
|
-
// ]
|
|
30
|
-
// `);
|
|
31
|
-
// }, 60000);
|
|
27
|
+
// it('view function some value', async () => {
|
|
28
|
+
// const payload = createViewPayload(OPTION_ABI, {
|
|
29
|
+
// function: 'test_option_view',
|
|
30
|
+
// functionArguments: [{ vec: ['50'] } as any],
|
|
31
|
+
// typeArguments: [],
|
|
32
|
+
// });
|
|
33
|
+
// const result = await client.view({ payload });
|
|
34
|
+
// expect(result).toMatchInlineSnapshot(`
|
|
35
|
+
// [
|
|
36
|
+
// "50",
|
|
37
|
+
// ]
|
|
38
|
+
// `);
|
|
39
|
+
// }, 60000);
|
|
32
40
|
|
|
33
|
-
// it('view function none value', async () => {
|
|
34
|
-
// const payload = createViewPayload(OPTION_ABI, {
|
|
35
|
-
// function: 'test_option_view',
|
|
36
|
-
// functionArguments: [{ vec: [] } as any],
|
|
37
|
-
// typeArguments: [],
|
|
38
|
-
// });
|
|
39
|
-
// const result = await client.view({ payload });
|
|
40
|
-
// expect(result).toMatchInlineSnapshot(`
|
|
41
|
-
// [
|
|
42
|
-
// "0",
|
|
43
|
-
// ]
|
|
44
|
-
// `);
|
|
45
|
-
// }, 60000);
|
|
41
|
+
// it('view function none value', async () => {
|
|
42
|
+
// const payload = createViewPayload(OPTION_ABI, {
|
|
43
|
+
// function: 'test_option_view',
|
|
44
|
+
// functionArguments: [{ vec: [] } as any],
|
|
45
|
+
// typeArguments: [],
|
|
46
|
+
// });
|
|
47
|
+
// const result = await client.view({ payload });
|
|
48
|
+
// expect(result).toMatchInlineSnapshot(`
|
|
49
|
+
// [
|
|
50
|
+
// "0",
|
|
51
|
+
// ]
|
|
52
|
+
// `);
|
|
53
|
+
// }, 60000);
|
|
46
54
|
|
|
47
55
|
it('entry function none value', async () => {
|
|
48
56
|
const payload = createEntryPayload(OPTION_ABI, {
|
|
49
57
|
function: 'test_option_entry',
|
|
50
|
-
functionArguments: [
|
|
58
|
+
functionArguments: [undefined],
|
|
51
59
|
typeArguments: [],
|
|
52
60
|
});
|
|
53
61
|
|
|
@@ -55,7 +63,7 @@ describe('option type', () => {
|
|
|
55
63
|
publicKey: account.publicKey,
|
|
56
64
|
sender: account.accountAddress.toString(),
|
|
57
65
|
payload,
|
|
58
|
-
})
|
|
66
|
+
});
|
|
59
67
|
|
|
60
68
|
expect(result?.hash).toBeDefined();
|
|
61
69
|
expect((result as any).payload).toMatchInlineSnapshot(`
|
|
@@ -83,7 +91,7 @@ describe('option type', () => {
|
|
|
83
91
|
publicKey: account.publicKey,
|
|
84
92
|
sender: account.accountAddress.toString(),
|
|
85
93
|
payload,
|
|
86
|
-
})
|
|
94
|
+
});
|
|
87
95
|
|
|
88
96
|
expect(result?.hash).toBeDefined();
|
|
89
97
|
expect((result as any).payload).toMatchInlineSnapshot(`
|
|
@@ -111,7 +111,7 @@ describe('useABI', () => {
|
|
|
111
111
|
account,
|
|
112
112
|
isSimulation: true,
|
|
113
113
|
});
|
|
114
|
-
|
|
114
|
+
|
|
115
115
|
expect(result?.hash).toBeDefined();
|
|
116
116
|
expect((result as any).payload).toMatchInlineSnapshot(`
|
|
117
117
|
{
|
|
@@ -143,6 +143,15 @@ const TEST_ABI = {
|
|
|
143
143
|
params: ['address', 'address'],
|
|
144
144
|
return: [],
|
|
145
145
|
},
|
|
146
|
+
{
|
|
147
|
+
name: 'pick_a_random_number',
|
|
148
|
+
visibility: 'private',
|
|
149
|
+
is_entry: true,
|
|
150
|
+
is_view: false,
|
|
151
|
+
generic_type_params: [],
|
|
152
|
+
params: [],
|
|
153
|
+
return: [],
|
|
154
|
+
}
|
|
146
155
|
],
|
|
147
156
|
structs: [],
|
|
148
157
|
} as const;
|
package/src/types/abi.ts
CHANGED
|
@@ -12,7 +12,7 @@ export interface ABIRoot {
|
|
|
12
12
|
|
|
13
13
|
export interface ABIFunction {
|
|
14
14
|
name: string;
|
|
15
|
-
visibility: 'friend' | 'public';
|
|
15
|
+
visibility: 'friend' | 'public' | 'private';
|
|
16
16
|
is_entry: boolean;
|
|
17
17
|
is_view: boolean;
|
|
18
18
|
generic_type_params: readonly ABIFunctionGenericTypeParam[];
|
|
@@ -30,32 +30,32 @@ type ConvertPrimitiveArgType<TMoveType extends MovePrimitive> =
|
|
|
30
30
|
TMoveType extends 'bool'
|
|
31
31
|
? boolean
|
|
32
32
|
: TMoveType extends 'u8'
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
33
|
+
? number
|
|
34
|
+
: TMoveType extends 'u16'
|
|
35
|
+
? number
|
|
36
|
+
: TMoveType extends 'u32'
|
|
37
|
+
? number
|
|
38
|
+
: TMoveType extends 'u64'
|
|
39
|
+
? AnyNumber
|
|
40
|
+
: TMoveType extends 'u128'
|
|
41
|
+
? AnyNumber
|
|
42
|
+
: TMoveType extends 'u256'
|
|
43
|
+
? AnyNumber
|
|
44
|
+
: TMoveType extends 'address'
|
|
45
|
+
? `0x${string}`
|
|
46
|
+
: TMoveType extends '0x1::string::String'
|
|
47
|
+
? string
|
|
48
|
+
: never;
|
|
49
49
|
|
|
50
50
|
type ConvertNonStructArgType<TMoveType extends MoveNonStructTypes> =
|
|
51
51
|
TMoveType extends MovePrimitive
|
|
52
52
|
? ConvertPrimitiveArgType<TMoveType>
|
|
53
53
|
: TMoveType extends `vector<u8>`
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
54
|
+
? string | number[] | Uint8Array
|
|
55
|
+
: TMoveType extends `vector<${infer TInner}>`
|
|
56
|
+
? ConvertArgType<TInner>[]
|
|
57
|
+
: TMoveType extends `0x1::object::Object<${string}>`
|
|
58
|
+
? `0x${string}`
|
|
59
|
+
: TMoveType extends `0x1::option::Option<${infer TInner}>`
|
|
60
|
+
? ConvertArgType<TInner> | undefined
|
|
61
|
+
: UnknownStruct<TMoveType>;
|