@thalalabs/surf 0.0.5 → 0.0.7
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/README.md +4 -6
- package/build/cjs/abi/aptos_coin.js +158 -0
- package/build/cjs/abi/aptos_coin.js.map +1 -0
- package/build/cjs/abi/coin.js +783 -0
- package/build/cjs/abi/coin.js.map +1 -0
- package/build/cjs/abi/event.js +138 -0
- package/build/cjs/abi/event.js.map +1 -0
- package/build/cjs/abi/fixed_point64.js +380 -0
- package/build/cjs/abi/fixed_point64.js.map +1 -0
- package/build/cjs/abi/guid.js +158 -0
- package/build/cjs/abi/guid.js.map +1 -0
- package/build/cjs/abi/table.js +299 -0
- package/build/cjs/abi/table.js.map +1 -0
- package/build/cjs/core/Client.js +12 -1
- package/build/cjs/core/Client.js.map +1 -1
- package/build/cjs/core/createEntryPayload.js.map +1 -1
- package/build/cjs/core/createViewPayload.js.map +1 -1
- package/build/cjs/hooks/useSubmitTransaction.js.map +1 -1
- package/build/cjs/types/globalABI.js +3 -0
- package/build/cjs/types/globalABI.js.map +1 -0
- package/build/cjs/types/struct.js +3 -0
- package/build/cjs/types/struct.js.map +1 -0
- package/build/esm/abi/aptos_coin.js +155 -0
- package/build/esm/abi/aptos_coin.js.map +1 -0
- package/build/esm/abi/coin.js +780 -0
- package/build/esm/abi/coin.js.map +1 -0
- package/build/esm/abi/event.js +135 -0
- package/build/esm/abi/event.js.map +1 -0
- package/build/esm/abi/fixed_point64.js +377 -0
- package/build/esm/abi/fixed_point64.js.map +1 -0
- package/build/esm/abi/guid.js +155 -0
- package/build/esm/abi/guid.js.map +1 -0
- package/build/esm/abi/table.js +296 -0
- package/build/esm/abi/table.js.map +1 -0
- package/build/esm/core/Client.js +12 -1
- package/build/esm/core/Client.js.map +1 -1
- package/build/esm/core/createEntryPayload.js.map +1 -1
- package/build/esm/core/createViewPayload.js.map +1 -1
- package/build/esm/hooks/useSubmitTransaction.js.map +1 -1
- package/build/esm/types/globalABI.js +2 -0
- package/build/esm/types/globalABI.js.map +1 -0
- package/build/esm/types/struct.js +2 -0
- package/build/esm/types/struct.js.map +1 -0
- package/build/types/abi/aptos_coin.d.ts +100 -0
- package/build/types/abi/aptos_coin.d.ts.map +1 -0
- package/build/types/abi/coin.d.ts +476 -0
- package/build/types/abi/coin.d.ts.map +1 -0
- package/build/types/abi/event.d.ts +72 -0
- package/build/types/abi/event.d.ts.map +1 -0
- package/build/types/abi/fixed_point64.d.ts +225 -0
- package/build/types/abi/fixed_point64.d.ts.map +1 -0
- package/build/types/abi/guid.d.ts +93 -0
- package/build/types/abi/guid.d.ts.map +1 -0
- package/build/types/abi/table.d.ts +152 -0
- package/build/types/abi/table.d.ts.map +1 -0
- package/build/types/core/Client.d.ts +2 -0
- package/build/types/core/Client.d.ts.map +1 -1
- package/build/types/hooks/useSubmitTransaction.d.ts.map +1 -1
- package/build/types/types/abiClient.d.ts +10 -0
- package/build/types/types/abiClient.d.ts.map +1 -1
- package/build/types/types/common.d.ts.map +1 -1
- package/build/types/types/globalABI.d.ts +13 -0
- package/build/types/types/globalABI.d.ts.map +1 -0
- package/build/types/types/struct.d.ts +25 -0
- package/build/types/types/struct.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/abi/aptos_coin.ts +154 -0
- package/src/abi/coin.ts +779 -0
- package/src/abi/event.ts +134 -0
- package/src/abi/fixed_point64.ts +376 -0
- package/src/abi/guid.ts +154 -0
- package/src/abi/table.ts +295 -0
- package/src/core/Client.ts +19 -2
- package/src/core/__tests__/accountResource.test.ts +39 -0
- package/src/core/__tests__/createEntryPayload.test.ts +1 -1
- package/src/core/__tests__/view.test.ts +1 -1
- package/src/core/__tests__/view_vector.test.ts +1 -1
- package/src/core/createEntryPayload.ts +0 -2
- package/src/core/createViewPayload.ts +4 -7
- package/src/hooks/useSubmitTransaction.ts +1 -0
- package/src/types/abiClient.ts +12 -1
- package/src/types/common.ts +2 -1
- package/src/types/globalABI.ts +13 -0
- package/src/types/struct.ts +78 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @thalalabs/surf
|
|
2
2
|
|
|
3
|
+
## 0.0.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 5d6d75b: Bug fix: abi files are missing in the package
|
|
8
|
+
|
|
9
|
+
## 0.0.6
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 2618838: Add a getAccountResource API in useABI client
|
|
14
|
+
- 4609afb: Add some builtin 0x1 types for getting account resource
|
|
15
|
+
|
|
3
16
|
## 0.0.5
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
- **Get rid of encoding/decoding**: Surf takes care of the complexities within the APIs, so you don't have to.
|
|
29
29
|
- **Linting and Auto-Completion**: Enjoy a better development experience with type safety. No more guesswork for input and output.
|
|
30
30
|
- **Both TypeScript Interfaces & React Hooks**: Easy to use, whether working with wallets or private keys.
|
|
31
|
-
- **Low runtime cost & small bundle size**: [minzipped size:
|
|
31
|
+
- **Low runtime cost & small bundle size**: [minzipped size: < 2 kB](https://bundlephobia.com/package/@thalalabs/surf).
|
|
32
32
|
|
|
33
33
|
## Overview
|
|
34
34
|
|
|
@@ -75,7 +75,7 @@ const client = createClient({
|
|
|
75
75
|
});
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
-
Surf infers types from ABI to give you the end-to-end type-safety from your Move contract to your frontend. So firstly, you need to prepare the ABI json object of your contract in TypeScript:
|
|
78
|
+
Surf infers types from ABI to give you the end-to-end type-safety from your Move contract to your frontend. So firstly, you need to prepare the ABI json object of your contract in TypeScript (You can get ABI from Aptos Explorer, for example: [0x1::coin](https://explorer.aptoslabs.com/account/0x1/modules/code/coin?network=testnet)):
|
|
79
79
|
|
|
80
80
|
```TypeScript
|
|
81
81
|
const abi = {…} as const;
|
|
@@ -173,10 +173,8 @@ Surf currently offers two React Hooks: `useWalletClient` and `useSubmitTransacti
|
|
|
173
173
|
Compared to [Viem](https://viem.sh/), Surf is still in its infancy. Any contribution is welcome and appreciated. Here are some TODOs:
|
|
174
174
|
|
|
175
175
|
- [ ] Deploy a dedicated smart contract on the testnet for Surf to run tests that cover all data types. Currently, Surf has some tests running in CI, but they do not cover all types.
|
|
176
|
-
- [ ] Support `struct` types for
|
|
177
|
-
|
|
178
|
-
- [ ] For `submitTransaction` function, Surf currently cannot encode for `struct` types.
|
|
179
|
-
- [ ] Support vector of vector, vector of struct.
|
|
176
|
+
- [ ] Support `struct` types for return values for `view` function.
|
|
177
|
+
- [ ] Support vector of vector.
|
|
180
178
|
- [ ] Accept `Uint8Array` and `string` for `vector<u8>` input. Currently users can pass these values to `createEntryPayload`, and Surf will correctly encode it. But the type system will complain. So users need to use `as any` to pass `Uint8Array` or `string` for `vector<u8>`. The type system only accept `number[]` for `vector<u8>` now.
|
|
181
179
|
- [ ] Add the functionality available in AptosClient to Surf, such as `estimateGasPrice` and `getAccountResources`.
|
|
182
180
|
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.APTOS_COIN_ABI = void 0;
|
|
4
|
+
exports.APTOS_COIN_ABI = {
|
|
5
|
+
"address": "0x1",
|
|
6
|
+
"name": "aptos_coin",
|
|
7
|
+
"friends": [
|
|
8
|
+
"0x1::genesis"
|
|
9
|
+
],
|
|
10
|
+
"exposed_functions": [
|
|
11
|
+
{
|
|
12
|
+
"name": "claim_mint_capability",
|
|
13
|
+
"visibility": "public",
|
|
14
|
+
"is_entry": true,
|
|
15
|
+
"is_view": false,
|
|
16
|
+
"generic_type_params": [],
|
|
17
|
+
"params": [
|
|
18
|
+
"&signer"
|
|
19
|
+
],
|
|
20
|
+
"return": []
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "configure_accounts_for_test",
|
|
24
|
+
"visibility": "friend",
|
|
25
|
+
"is_entry": false,
|
|
26
|
+
"is_view": false,
|
|
27
|
+
"generic_type_params": [],
|
|
28
|
+
"params": [
|
|
29
|
+
"&signer",
|
|
30
|
+
"&signer",
|
|
31
|
+
"0x1::coin::MintCapability<0x1::aptos_coin::AptosCoin>"
|
|
32
|
+
],
|
|
33
|
+
"return": []
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"name": "delegate_mint_capability",
|
|
37
|
+
"visibility": "public",
|
|
38
|
+
"is_entry": true,
|
|
39
|
+
"is_view": false,
|
|
40
|
+
"generic_type_params": [],
|
|
41
|
+
"params": [
|
|
42
|
+
"signer",
|
|
43
|
+
"address"
|
|
44
|
+
],
|
|
45
|
+
"return": []
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"name": "destroy_mint_cap",
|
|
49
|
+
"visibility": "friend",
|
|
50
|
+
"is_entry": false,
|
|
51
|
+
"is_view": false,
|
|
52
|
+
"generic_type_params": [],
|
|
53
|
+
"params": [
|
|
54
|
+
"&signer"
|
|
55
|
+
],
|
|
56
|
+
"return": []
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"name": "has_mint_capability",
|
|
60
|
+
"visibility": "public",
|
|
61
|
+
"is_entry": false,
|
|
62
|
+
"is_view": false,
|
|
63
|
+
"generic_type_params": [],
|
|
64
|
+
"params": [
|
|
65
|
+
"&signer"
|
|
66
|
+
],
|
|
67
|
+
"return": [
|
|
68
|
+
"bool"
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"name": "initialize",
|
|
73
|
+
"visibility": "friend",
|
|
74
|
+
"is_entry": false,
|
|
75
|
+
"is_view": false,
|
|
76
|
+
"generic_type_params": [],
|
|
77
|
+
"params": [
|
|
78
|
+
"&signer"
|
|
79
|
+
],
|
|
80
|
+
"return": [
|
|
81
|
+
"0x1::coin::BurnCapability<0x1::aptos_coin::AptosCoin>",
|
|
82
|
+
"0x1::coin::MintCapability<0x1::aptos_coin::AptosCoin>"
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"name": "mint",
|
|
87
|
+
"visibility": "public",
|
|
88
|
+
"is_entry": true,
|
|
89
|
+
"is_view": false,
|
|
90
|
+
"generic_type_params": [],
|
|
91
|
+
"params": [
|
|
92
|
+
"&signer",
|
|
93
|
+
"address",
|
|
94
|
+
"u64"
|
|
95
|
+
],
|
|
96
|
+
"return": []
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
"structs": [
|
|
100
|
+
{
|
|
101
|
+
"name": "AptosCoin",
|
|
102
|
+
"is_native": false,
|
|
103
|
+
"abilities": [
|
|
104
|
+
"key"
|
|
105
|
+
],
|
|
106
|
+
"generic_type_params": [],
|
|
107
|
+
"fields": [
|
|
108
|
+
{
|
|
109
|
+
"name": "dummy_field",
|
|
110
|
+
"type": "bool"
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"name": "DelegatedMintCapability",
|
|
116
|
+
"is_native": false,
|
|
117
|
+
"abilities": [
|
|
118
|
+
"store"
|
|
119
|
+
],
|
|
120
|
+
"generic_type_params": [],
|
|
121
|
+
"fields": [
|
|
122
|
+
{
|
|
123
|
+
"name": "to",
|
|
124
|
+
"type": "address"
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"name": "Delegations",
|
|
130
|
+
"is_native": false,
|
|
131
|
+
"abilities": [
|
|
132
|
+
"key"
|
|
133
|
+
],
|
|
134
|
+
"generic_type_params": [],
|
|
135
|
+
"fields": [
|
|
136
|
+
{
|
|
137
|
+
"name": "inner",
|
|
138
|
+
"type": "vector<0x1::aptos_coin::DelegatedMintCapability>"
|
|
139
|
+
}
|
|
140
|
+
]
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"name": "MintCapStore",
|
|
144
|
+
"is_native": false,
|
|
145
|
+
"abilities": [
|
|
146
|
+
"key"
|
|
147
|
+
],
|
|
148
|
+
"generic_type_params": [],
|
|
149
|
+
"fields": [
|
|
150
|
+
{
|
|
151
|
+
"name": "mint_cap",
|
|
152
|
+
"type": "0x1::coin::MintCapability<0x1::aptos_coin::AptosCoin>"
|
|
153
|
+
}
|
|
154
|
+
]
|
|
155
|
+
}
|
|
156
|
+
]
|
|
157
|
+
};
|
|
158
|
+
//# sourceMappingURL=aptos_coin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aptos_coin.js","sourceRoot":"","sources":["../../../src/abi/aptos_coin.ts"],"names":[],"mappings":";;;AAAa,QAAA,cAAc,GAAG;IAC1B,SAAS,EAAE,KAAK;IAChB,MAAM,EAAE,YAAY;IACpB,SAAS,EAAE;QACP,cAAc;KACjB;IACD,mBAAmB,EAAE;QACjB;YACI,MAAM,EAAE,uBAAuB;YAC/B,YAAY,EAAE,QAAQ;YACtB,UAAU,EAAE,IAAI;YAChB,SAAS,EAAE,KAAK;YAChB,qBAAqB,EAAE,EAAE;YACzB,QAAQ,EAAE;gBACN,SAAS;aACZ;YACD,QAAQ,EAAE,EAAE;SACf;QACD;YACI,MAAM,EAAE,6BAA6B;YACrC,YAAY,EAAE,QAAQ;YACtB,UAAU,EAAE,KAAK;YACjB,SAAS,EAAE,KAAK;YAChB,qBAAqB,EAAE,EAAE;YACzB,QAAQ,EAAE;gBACN,SAAS;gBACT,SAAS;gBACT,uDAAuD;aAC1D;YACD,QAAQ,EAAE,EAAE;SACf;QACD;YACI,MAAM,EAAE,0BAA0B;YAClC,YAAY,EAAE,QAAQ;YACtB,UAAU,EAAE,IAAI;YAChB,SAAS,EAAE,KAAK;YAChB,qBAAqB,EAAE,EAAE;YACzB,QAAQ,EAAE;gBACN,QAAQ;gBACR,SAAS;aACZ;YACD,QAAQ,EAAE,EAAE;SACf;QACD;YACI,MAAM,EAAE,kBAAkB;YAC1B,YAAY,EAAE,QAAQ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