@sentio/sdk 1.27.1 → 1.27.3
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/aptos/types.js +4 -3
- package/lib/aptos/types.js.map +1 -1
- package/lib/aptos/types.test.d.ts +1 -0
- package/lib/aptos/types.test.js +19 -0
- package/lib/aptos/types.test.js.map +1 -0
- package/lib/aptos/utils.d.ts +4 -1
- package/lib/aptos/utils.js +16 -1
- package/lib/aptos/utils.js.map +1 -1
- package/lib/aptos-codegen/codegen.js +15 -21
- package/lib/aptos-codegen/codegen.js.map +1 -1
- package/lib/builtin/aptos/0x1.d.ts +8 -8
- package/lib/builtin/aptos/0x1.js.map +1 -1
- package/lib/builtin/aptos/0x3.d.ts +1 -1
- package/lib/builtin/aptos/0x3.js.map +1 -1
- package/lib/cli/upload.js +17 -2
- package/lib/cli/upload.js.map +1 -1
- package/lib/gen/chainquery/protos/chainquery.d.ts +223 -0
- package/lib/gen/chainquery/protos/chainquery.js +628 -0
- package/lib/gen/chainquery/protos/chainquery.js.map +1 -0
- package/lib/tests/aptos.test.js +76 -1
- package/lib/tests/aptos.test.js.map +1 -1
- package/lib/tests/souffl3.js +3 -0
- package/lib/tests/souffl3.js.map +1 -1
- package/lib/tests/types/aptos/soffl3.d.ts +786 -0
- package/lib/tests/types/aptos/soffl3.js +559 -0
- package/lib/tests/types/aptos/soffl3.js.map +1 -0
- package/lib/tests/types/aptos/souffle.d.ts +16 -16
- package/lib/tests/types/aptos/souffle.js.map +1 -1
- package/package.json +1 -1
- package/src/aptos/types.test.ts +18 -0
- package/src/aptos/types.ts +5 -4
- package/src/aptos/utils.ts +18 -1
- package/src/aptos-codegen/codegen.ts +16 -23
- package/src/builtin/aptos/0x1.ts +9 -8
- package/src/builtin/aptos/0x3.ts +1 -1
- package/src/cli/upload.ts +17 -2
- package/src/gen/chainquery/protos/chainquery.ts +840 -0
- package/src/tests/abis/aptos/soffl3.json +1411 -0
- package/src/tests/aptos.test.ts +79 -1
- package/src/tests/souffl3.ts +5 -1
- package/src/tests/types/aptos/soffl3.ts +1377 -0
- package/src/tests/types/aptos/souffle.ts +16 -16
@@ -3,7 +3,7 @@ import path from 'path'
|
|
3
3
|
import prettier from 'prettier'
|
4
4
|
import { MoveFunction, MoveModule, MoveModuleBytecode, MoveStruct } from 'aptos-sdk/src/generated'
|
5
5
|
import { AccountModulesImportInfo, AccountRegister, generateType, parseMoveType } from './typegen'
|
6
|
-
import { isFrameworkAccount, moduleQname, SPLITTER } from '../aptos/utils'
|
6
|
+
import { getMeaningfulFunctionParams, isFrameworkAccount, moduleQname, SPLITTER } from '../aptos/utils'
|
7
7
|
import chalk from 'chalk'
|
8
8
|
import { AptosNetwork, getChainName, getRpcClient } from '../aptos/network'
|
9
9
|
|
@@ -292,18 +292,18 @@ function generateStructs(module: MoveModule, struct: MoveStruct, events: Set<str
|
|
292
292
|
`
|
293
293
|
}
|
294
294
|
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
295
|
+
function generateFunctionTypeParameters(func: MoveFunction) {
|
296
|
+
let genericString = ''
|
297
|
+
if (func.generic_type_params && func.generic_type_params.length > 0) {
|
298
|
+
const params = func.generic_type_params
|
299
|
+
.map((v, idx) => {
|
300
|
+
return `T${idx}=any`
|
301
|
+
})
|
302
|
+
.join(',')
|
303
|
+
genericString = `<${params}>`
|
304
|
+
}
|
305
|
+
return genericString
|
306
|
+
}
|
307
307
|
|
308
308
|
function generateStructTypeParameters(struct: MoveStruct, useAny = false) {
|
309
309
|
let genericString = ''
|
@@ -324,22 +324,15 @@ function generateCallArgsStructs(module: MoveModule, func: MoveFunction) {
|
|
324
324
|
return
|
325
325
|
}
|
326
326
|
|
327
|
-
|
328
|
-
// TODO check if there is any edge case
|
329
|
-
let params = func.params
|
330
|
-
if (func.params[0] === '&signer') {
|
331
|
-
params = params.slice(1)
|
332
|
-
}
|
333
|
-
|
334
|
-
const fields = params.map((param) => {
|
327
|
+
const fields = getMeaningfulFunctionParams(func).map((param) => {
|
335
328
|
return `${generateType(param)}`
|
336
329
|
})
|
337
330
|
|
338
331
|
const camelFuncName = capitalizeFirstChar(camelize(func.name))
|
339
332
|
|
340
|
-
|
333
|
+
const genericString = generateFunctionTypeParameters(func)
|
341
334
|
return `
|
342
|
-
export interface ${camelFuncName}Payload
|
335
|
+
export interface ${camelFuncName}Payload${genericString}
|
343
336
|
extends aptos.TypedEntryFunctionPayload<[${fields.join(',')}]> {
|
344
337
|
arguments_typed: [${fields.join(',')}],
|
345
338
|
type_arguments: [${func.generic_type_params.map((_) => 'string').join(', ')}]
|
package/src/builtin/aptos/0x1.ts
CHANGED
@@ -281,25 +281,25 @@ export namespace coin {
|
|
281
281
|
type_arguments: [];
|
282
282
|
}
|
283
283
|
|
284
|
-
export interface FreezeCoinStorePayload
|
284
|
+
export interface FreezeCoinStorePayload<T0 = any>
|
285
285
|
extends aptos.TypedEntryFunctionPayload<[Address, Address]> {
|
286
286
|
arguments_typed: [Address, Address];
|
287
287
|
type_arguments: [string];
|
288
288
|
}
|
289
289
|
|
290
|
-
export interface TransferPayload
|
290
|
+
export interface TransferPayload<T0 = any>
|
291
291
|
extends aptos.TypedEntryFunctionPayload<[Address, bigint]> {
|
292
292
|
arguments_typed: [Address, bigint];
|
293
293
|
type_arguments: [string];
|
294
294
|
}
|
295
295
|
|
296
|
-
export interface UnfreezeCoinStorePayload
|
296
|
+
export interface UnfreezeCoinStorePayload<T0 = any>
|
297
297
|
extends aptos.TypedEntryFunctionPayload<[Address, Address]> {
|
298
298
|
arguments_typed: [Address, Address];
|
299
299
|
type_arguments: [string];
|
300
300
|
}
|
301
301
|
|
302
|
-
export interface UpgradeSupplyPayload
|
302
|
+
export interface UpgradeSupplyPayload<T0 = any>
|
303
303
|
extends aptos.TypedEntryFunctionPayload<[]> {
|
304
304
|
arguments_typed: [];
|
305
305
|
type_arguments: [string];
|
@@ -2767,25 +2767,26 @@ export namespace managed_coin {
|
|
2767
2767
|
mint_cap: coin.MintCapability<T0>;
|
2768
2768
|
}
|
2769
2769
|
|
2770
|
-
export interface BurnPayload
|
2770
|
+
export interface BurnPayload<T0 = any>
|
2771
2771
|
extends aptos.TypedEntryFunctionPayload<[bigint]> {
|
2772
2772
|
arguments_typed: [bigint];
|
2773
2773
|
type_arguments: [string];
|
2774
2774
|
}
|
2775
2775
|
|
2776
|
-
export interface InitializePayload
|
2776
|
+
export interface InitializePayload<T0 = any>
|
2777
2777
|
extends aptos.TypedEntryFunctionPayload<[string, string, number, Boolean]> {
|
2778
2778
|
arguments_typed: [string, string, number, Boolean];
|
2779
2779
|
type_arguments: [string];
|
2780
2780
|
}
|
2781
2781
|
|
2782
|
-
export interface MintPayload
|
2782
|
+
export interface MintPayload<T0 = any>
|
2783
2783
|
extends aptos.TypedEntryFunctionPayload<[Address, bigint]> {
|
2784
2784
|
arguments_typed: [Address, bigint];
|
2785
2785
|
type_arguments: [string];
|
2786
2786
|
}
|
2787
2787
|
|
2788
|
-
export interface RegisterPayload
|
2788
|
+
export interface RegisterPayload<T0 = any>
|
2789
|
+
extends aptos.TypedEntryFunctionPayload<[]> {
|
2789
2790
|
arguments_typed: [];
|
2790
2791
|
type_arguments: [string];
|
2791
2792
|
}
|
package/src/builtin/aptos/0x3.ts
CHANGED
@@ -666,7 +666,7 @@ export namespace token_coin_swap {
|
|
666
666
|
type_arguments: [];
|
667
667
|
}
|
668
668
|
|
669
|
-
export interface ListTokenForSwapPayload
|
669
|
+
export interface ListTokenForSwapPayload<T0 = any>
|
670
670
|
extends aptos.TypedEntryFunctionPayload<
|
671
671
|
[Address, string, string, bigint, bigint, bigint, bigint]
|
672
672
|
> {
|
package/src/cli/upload.ts
CHANGED
@@ -53,6 +53,7 @@ export async function uploadFile(options: SentioProjectConfig, apiKeyOverride: s
|
|
53
53
|
hash.update(content)
|
54
54
|
const digest = hash.digest('hex')
|
55
55
|
|
56
|
+
let triedCount = 0
|
56
57
|
const upload = async () => {
|
57
58
|
const data = new FormData()
|
58
59
|
data.append('attachment', fs.createReadStream(PROCESSOR_FILE))
|
@@ -71,7 +72,7 @@ export async function uploadFile(options: SentioProjectConfig, apiKeyOverride: s
|
|
71
72
|
} catch (e) {
|
72
73
|
// skip errors
|
73
74
|
}
|
74
|
-
console.log(chalk.blue('Uploading'))
|
75
|
+
console.log(chalk.blue(triedCount > 1 ? 'Retry uploading' : 'Uploading'))
|
75
76
|
const res = await fetch(url, {
|
76
77
|
method: 'POST',
|
77
78
|
headers: {
|
@@ -125,5 +126,19 @@ export async function uploadFile(options: SentioProjectConfig, apiKeyOverride: s
|
|
125
126
|
}
|
126
127
|
}
|
127
128
|
|
128
|
-
|
129
|
+
const tryUploading = async () => {
|
130
|
+
if (triedCount++ >= 5) {
|
131
|
+
return
|
132
|
+
}
|
133
|
+
try {
|
134
|
+
await upload()
|
135
|
+
} catch (e) {
|
136
|
+
console.log(e)
|
137
|
+
if (e.constructor.name === 'FetchError' && e.type === 'system' && e.code === 'EPIPE') {
|
138
|
+
await tryUploading()
|
139
|
+
}
|
140
|
+
}
|
141
|
+
}
|
142
|
+
|
143
|
+
await tryUploading()
|
129
144
|
}
|