@sentio/sdk 2.60.0-rc.4 → 2.60.0-rc.6
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/lib/eth/base-processor.d.ts +3 -1
- package/lib/eth/base-processor.d.ts.map +1 -1
- package/lib/eth/base-processor.js +26 -0
- package/lib/eth/base-processor.js.map +1 -1
- package/lib/eth/eth-plugin.d.ts.map +1 -1
- package/lib/eth/eth-plugin.js +37 -3
- package/lib/eth/eth-plugin.js.map +1 -1
- package/lib/iota/builtin/0x1.d.ts +817 -0
- package/lib/iota/builtin/0x1.d.ts.map +1 -0
- package/lib/iota/builtin/0x1.js +4385 -0
- package/lib/iota/builtin/0x1.js.map +1 -0
- package/lib/iota/builtin/0x2.d.ts +4529 -0
- package/lib/iota/builtin/0x2.d.ts.map +1 -0
- package/lib/iota/builtin/0x2.js +17109 -0
- package/lib/iota/builtin/0x2.js.map +1 -0
- package/lib/iota/builtin/0x3.d.ts +2293 -0
- package/lib/iota/builtin/0x3.d.ts.map +1 -0
- package/lib/iota/builtin/0x3.js +6522 -0
- package/lib/iota/builtin/0x3.js.map +1 -0
- package/lib/iota/builtin/index.d.ts +4 -0
- package/lib/iota/builtin/index.d.ts.map +1 -0
- package/lib/iota/builtin/index.js +7 -0
- package/lib/iota/builtin/index.js.map +1 -0
- package/lib/iota/codegen/codegen.d.ts +2 -0
- package/lib/iota/codegen/codegen.d.ts.map +1 -0
- package/lib/iota/codegen/codegen.js +94 -0
- package/lib/iota/codegen/codegen.js.map +1 -0
- package/lib/iota/codegen/index.d.ts +2 -0
- package/lib/iota/codegen/index.d.ts.map +1 -0
- package/lib/iota/codegen/index.js +2 -0
- package/lib/iota/codegen/index.js.map +1 -0
- package/lib/iota/codegen/run.d.ts +2 -0
- package/lib/iota/codegen/run.d.ts.map +1 -0
- package/lib/iota/codegen/run.js +12 -0
- package/lib/iota/codegen/run.js.map +1 -0
- package/lib/iota/context.d.ts +50 -0
- package/lib/iota/context.d.ts.map +1 -0
- package/lib/iota/context.js +134 -0
- package/lib/iota/context.js.map +1 -0
- package/lib/iota/ext/coin.d.ts +17 -0
- package/lib/iota/ext/coin.d.ts.map +1 -0
- package/lib/iota/ext/coin.js +532 -0
- package/lib/iota/ext/coin.js.map +1 -0
- package/lib/iota/ext/index.d.ts +3 -0
- package/lib/iota/ext/index.d.ts.map +1 -0
- package/lib/iota/ext/index.js +3 -0
- package/lib/iota/ext/index.js.map +1 -0
- package/lib/iota/ext/move-dex.d.ts +19 -0
- package/lib/iota/ext/move-dex.d.ts.map +1 -0
- package/lib/iota/ext/move-dex.js +24 -0
- package/lib/iota/ext/move-dex.js.map +1 -0
- package/lib/iota/index.d.ts +11 -0
- package/lib/iota/index.d.ts.map +1 -0
- package/lib/iota/index.js +12 -0
- package/lib/iota/index.js.map +1 -0
- package/lib/iota/iota-object-processor-template.d.ts +44 -0
- package/lib/iota/iota-object-processor-template.d.ts.map +1 -0
- package/lib/iota/iota-object-processor-template.js +171 -0
- package/lib/iota/iota-object-processor-template.js.map +1 -0
- package/lib/iota/iota-object-processor.d.ts +83 -0
- package/lib/iota/iota-object-processor.d.ts.map +1 -0
- package/lib/iota/iota-object-processor.js +193 -0
- package/lib/iota/iota-object-processor.js.map +1 -0
- package/lib/iota/iota-plugin-part.d.ts +12 -0
- package/lib/iota/iota-plugin-part.d.ts.map +1 -0
- package/lib/iota/iota-plugin-part.js +178 -0
- package/lib/iota/iota-plugin-part.js.map +1 -0
- package/lib/iota/iota-plugin.d.ts +3 -0
- package/lib/iota/iota-plugin.d.ts.map +1 -0
- package/lib/iota/iota-plugin.js +4 -0
- package/lib/iota/iota-plugin.js.map +1 -0
- package/lib/iota/iota-processor.d.ts +47 -0
- package/lib/iota/iota-processor.d.ts.map +1 -0
- package/lib/iota/iota-processor.js +223 -0
- package/lib/iota/iota-processor.js.map +1 -0
- package/lib/iota/models.d.ts +12 -0
- package/lib/iota/models.d.ts.map +1 -0
- package/lib/iota/models.js +2 -0
- package/lib/iota/models.js.map +1 -0
- package/lib/iota/move-coder.d.ts +4 -0
- package/lib/iota/move-coder.d.ts.map +1 -0
- package/lib/iota/move-coder.js +12 -0
- package/lib/iota/move-coder.js.map +1 -0
- package/lib/iota/network.d.ts +10 -0
- package/lib/iota/network.d.ts.map +1 -0
- package/lib/iota/network.js +24 -0
- package/lib/iota/network.js.map +1 -0
- package/lib/iota/utils.d.ts +3 -0
- package/lib/iota/utils.d.ts.map +1 -0
- package/lib/iota/utils.js +41 -0
- package/lib/iota/utils.js.map +1 -0
- package/lib/sui/network.d.ts.map +1 -1
- package/lib/sui/network.js +0 -3
- package/lib/sui/network.js.map +1 -1
- package/lib/sui/sui-plugin-part.d.ts +12 -0
- package/lib/sui/sui-plugin-part.d.ts.map +1 -0
- package/lib/sui/sui-plugin-part.js +178 -0
- package/lib/sui/sui-plugin-part.js.map +1 -0
- package/lib/sui/sui-plugin.d.ts +4 -0
- package/lib/sui/sui-plugin.d.ts.map +1 -1
- package/lib/sui/sui-plugin.js +12 -159
- package/lib/sui/sui-plugin.js.map +1 -1
- package/lib/testing/iota-facet.d.ts +14 -0
- package/lib/testing/iota-facet.d.ts.map +1 -0
- package/lib/testing/iota-facet.js +124 -0
- package/lib/testing/iota-facet.js.map +1 -0
- package/lib/testing/test-processor-server.d.ts +2 -0
- package/lib/testing/test-processor-server.d.ts.map +1 -1
- package/lib/testing/test-processor-server.js +3 -0
- package/lib/testing/test-processor-server.js.map +1 -1
- package/package.json +20 -8
- package/src/eth/base-processor.ts +43 -1
- package/src/eth/eth-plugin.ts +41 -3
- package/src/iota/abis/0x1.json +4213 -0
- package/src/iota/abis/0x2.json +26692 -0
- package/src/iota/abis/0x3.json +10598 -0
- package/src/iota/builtin/0x1.ts +6292 -0
- package/src/iota/builtin/0x2.ts +26198 -0
- package/src/iota/builtin/0x3.ts +11144 -0
- package/src/iota/builtin/index.ts +6 -0
- package/src/iota/codegen/codegen.ts +118 -0
- package/src/iota/codegen/index.ts +1 -0
- package/src/iota/codegen/run.ts +13 -0
- package/src/iota/context.ts +200 -0
- package/src/iota/ext/coin.ts +565 -0
- package/src/iota/ext/index.ts +2 -0
- package/src/iota/ext/move-dex.ts +52 -0
- package/src/iota/index.ts +29 -0
- package/src/iota/iota-object-processor-template.ts +277 -0
- package/src/iota/iota-object-processor.ts +386 -0
- package/src/iota/iota-plugin-part.ts +211 -0
- package/src/iota/iota-plugin.ts +2 -0
- package/src/iota/iota-processor.ts +339 -0
- package/src/iota/models.ts +14 -0
- package/src/iota/move-coder.ts +15 -0
- package/src/iota/network.ts +27 -0
- package/src/iota/utils.ts +52 -0
- package/src/sui/network.ts +0 -3
- package/src/sui/sui-plugin-part.ts +211 -0
- package/src/sui/sui-plugin.ts +12 -178
- package/src/testing/iota-facet.ts +143 -0
- package/src/testing/test-processor-server.ts +3 -0
@@ -0,0 +1,118 @@
|
|
1
|
+
import { IotaMoveNormalizedModule, IotaEvent, IotaMoveObject } from '@iota/iota-sdk/client'
|
2
|
+
|
3
|
+
import * as fs from 'fs'
|
4
|
+
import chalk from 'chalk'
|
5
|
+
import { InternalMoveModule, InternalMoveStruct, structQname } from '@typemove/move'
|
6
|
+
import { IotaCodegen as BaseIotaCodegen } from '@typemove/iota/codegen'
|
7
|
+
import path, { join } from 'path'
|
8
|
+
import { SharedNetworkCodegen } from '../../move/shared-network-codegen.js'
|
9
|
+
import { getRpcEndpoint, IotaNetwork } from '../network.js'
|
10
|
+
import { recursiveCodegen } from '../../core/codegen.js'
|
11
|
+
|
12
|
+
export async function codegen(
|
13
|
+
abisDir: string,
|
14
|
+
outDir = join('src', 'types', 'iota'),
|
15
|
+
genExample = false,
|
16
|
+
builtin = false
|
17
|
+
) {
|
18
|
+
if (!fs.existsSync(abisDir)) {
|
19
|
+
return
|
20
|
+
}
|
21
|
+
const gen = new IotaCodegen()
|
22
|
+
const numFiles = await gen.generate(abisDir, outDir, builtin)
|
23
|
+
console.log(chalk.green(`Generated ${numFiles} for Iota`))
|
24
|
+
}
|
25
|
+
|
26
|
+
class IotaNetworkCodegen extends BaseIotaCodegen {
|
27
|
+
moduleGenerator: SharedNetworkCodegen<IotaNetwork, IotaMoveNormalizedModule, IotaEvent | IotaMoveObject>
|
28
|
+
SYSTEM_PACKAGE = '@sentio/sdk/iota'
|
29
|
+
|
30
|
+
constructor(network: IotaNetwork) {
|
31
|
+
const endpoint = getRpcEndpoint(network)
|
32
|
+
super(endpoint)
|
33
|
+
const generator = this
|
34
|
+
this.moduleGenerator = new (class extends SharedNetworkCodegen<
|
35
|
+
IotaNetwork,
|
36
|
+
IotaMoveNormalizedModule,
|
37
|
+
IotaEvent | IotaMoveObject
|
38
|
+
> {
|
39
|
+
ADDRESS_TYPE = 'string'
|
40
|
+
PREFIX = 'Iota'
|
41
|
+
SYSTEM_PACKAGE = '@sentio/sdk/iota'
|
42
|
+
NETWORK = IotaNetwork
|
43
|
+
|
44
|
+
generateStructs(module: InternalMoveModule, struct: InternalMoveStruct, events: Set<string>): string {
|
45
|
+
let content = ''
|
46
|
+
switch (structQname(module, struct)) {
|
47
|
+
// TODO they should still have module code generated
|
48
|
+
case '0x1::ascii::Char':
|
49
|
+
case '0x1::ascii::String':
|
50
|
+
case '0x2::object::ID':
|
51
|
+
content += `export type ${struct.name} = string`
|
52
|
+
break
|
53
|
+
case '0x2::coin::Coin':
|
54
|
+
content += `export type ${struct.name}<T> = string`
|
55
|
+
break
|
56
|
+
case '0x2::balance::Balance':
|
57
|
+
content += `export type ${struct.name}<T> = bigint`
|
58
|
+
break
|
59
|
+
case '0x1::option::Option':
|
60
|
+
content += `export type Option<T> = T | undefined`
|
61
|
+
break
|
62
|
+
}
|
63
|
+
return content + super.generateStructs(module, struct, events, content !== '')
|
64
|
+
}
|
65
|
+
|
66
|
+
generateForOnEvents(module: InternalMoveModule, struct: InternalMoveStruct): string {
|
67
|
+
switch (structQname(module, struct)) {
|
68
|
+
case '0x1::ascii::Char':
|
69
|
+
case '0x1::ascii::String':
|
70
|
+
case '0x2::object::ID':
|
71
|
+
case '0x2::coin::Coin':
|
72
|
+
case '0x1::option::Option':
|
73
|
+
case '0x2::balance::Balance':
|
74
|
+
return ''
|
75
|
+
}
|
76
|
+
return super.generateForOnEvents(module, struct)
|
77
|
+
}
|
78
|
+
|
79
|
+
protected generateExtra(address: string | undefined, module: InternalMoveModule): string {
|
80
|
+
return generator.generateExtra(address, module)
|
81
|
+
}
|
82
|
+
})(network, this.chainAdapter)
|
83
|
+
}
|
84
|
+
|
85
|
+
generateModule(module: InternalMoveModule, allEventStructs: Map<string, InternalMoveStruct>) {
|
86
|
+
return this.moduleGenerator.generateModule(module, allEventStructs)
|
87
|
+
}
|
88
|
+
generateImports() {
|
89
|
+
return super.generateImports() + this.moduleGenerator.generateImports()
|
90
|
+
}
|
91
|
+
generateLoadAll(isSystem: boolean): string {
|
92
|
+
return this.moduleGenerator.generateLoadAll(isSystem)
|
93
|
+
}
|
94
|
+
}
|
95
|
+
//
|
96
|
+
const MAINNET_CODEGEN = new IotaNetworkCodegen(IotaNetwork.MAIN_NET)
|
97
|
+
const TESTNET_CODEGEN = new IotaNetworkCodegen(IotaNetwork.TEST_NET)
|
98
|
+
|
99
|
+
class IotaCodegen {
|
100
|
+
async generate(srcDir: string, outputDir: string, builtin = false): Promise<number> {
|
101
|
+
let numFiles = 0
|
102
|
+
const generators: [string, IotaNetworkCodegen][] = [
|
103
|
+
['', MAINNET_CODEGEN],
|
104
|
+
['testnet', TESTNET_CODEGEN]
|
105
|
+
]
|
106
|
+
|
107
|
+
for (const [network, gen] of generators) {
|
108
|
+
const exclude = network ? [] : ['testnet']
|
109
|
+
numFiles += await recursiveCodegen(
|
110
|
+
path.join(srcDir, network),
|
111
|
+
path.join(outputDir, network),
|
112
|
+
(src, dst) => gen.generate(src, dst, builtin),
|
113
|
+
exclude
|
114
|
+
)
|
115
|
+
}
|
116
|
+
return numFiles
|
117
|
+
}
|
118
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './codegen.js'
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// #!/usr/bin/env node
|
2
|
+
|
3
|
+
import { codegen } from './codegen.js'
|
4
|
+
|
5
|
+
if (process.argv.length > 3) {
|
6
|
+
const abisDir = process.argv[2]
|
7
|
+
const targetDir = process.argv[3]
|
8
|
+
|
9
|
+
await codegen(abisDir, targetDir, false, true)
|
10
|
+
} else {
|
11
|
+
console.error('Not enough argument')
|
12
|
+
process.exit(1)
|
13
|
+
}
|
@@ -0,0 +1,200 @@
|
|
1
|
+
import { RecordMetaData } from '@sentio/protos'
|
2
|
+
import { type Labels, normalizeLabels } from '../index.js'
|
3
|
+
import { getClient, IotaNetwork } from './network.js'
|
4
|
+
import {
|
5
|
+
IotaTransactionBlockResponse,
|
6
|
+
IotaEvent,
|
7
|
+
IotaMoveNormalizedModule,
|
8
|
+
IotaMoveObject,
|
9
|
+
IotaClient
|
10
|
+
} from '@iota/iota-sdk/client'
|
11
|
+
import { MoveCoder } from './index.js'
|
12
|
+
import { defaultMoveCoder } from './move-coder.js'
|
13
|
+
import { MoveAccountContext, MoveContext } from '../move/index.js'
|
14
|
+
|
15
|
+
export class IotaContext extends MoveContext<IotaNetwork, IotaMoveNormalizedModule, IotaEvent | IotaMoveObject> {
|
16
|
+
moduleName: string
|
17
|
+
timestamp: Date
|
18
|
+
checkpoint: bigint
|
19
|
+
transaction: IotaTransactionBlockResponse
|
20
|
+
eventIndex: number
|
21
|
+
coder: MoveCoder
|
22
|
+
|
23
|
+
constructor(
|
24
|
+
moduleName: string,
|
25
|
+
network: IotaNetwork,
|
26
|
+
address: string,
|
27
|
+
timestamp: Date,
|
28
|
+
checkpoint: bigint,
|
29
|
+
transaction: IotaTransactionBlockResponse,
|
30
|
+
eventIndex: number,
|
31
|
+
baseLabels: Labels | undefined
|
32
|
+
) {
|
33
|
+
super(baseLabels)
|
34
|
+
this.address = address.toLowerCase()
|
35
|
+
this.network = network
|
36
|
+
this.moduleName = moduleName
|
37
|
+
this.timestamp = timestamp
|
38
|
+
this.checkpoint = checkpoint
|
39
|
+
this.eventIndex = eventIndex
|
40
|
+
this.coder = defaultMoveCoder(network)
|
41
|
+
if (transaction) {
|
42
|
+
this.transaction = transaction
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
getChainId() {
|
47
|
+
return this.network
|
48
|
+
}
|
49
|
+
|
50
|
+
getTimestamp(): number {
|
51
|
+
return this.timestamp.getDate()
|
52
|
+
}
|
53
|
+
|
54
|
+
getMetaDataInternal(name: string, labels: Labels): RecordMetaData {
|
55
|
+
return {
|
56
|
+
address: this.address,
|
57
|
+
contractName: this.moduleName,
|
58
|
+
blockNumber: this.checkpoint,
|
59
|
+
transactionIndex: 0,
|
60
|
+
transactionHash: this.transaction?.digest || '', // TODO
|
61
|
+
logIndex: this.eventIndex,
|
62
|
+
chainId: this.getChainId(),
|
63
|
+
name: name,
|
64
|
+
labels: normalizeLabels(labels)
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
68
|
+
get client(): IotaClient {
|
69
|
+
return getClient(this.network)
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
export class IotaObjectChangeContext extends MoveContext<
|
74
|
+
IotaNetwork,
|
75
|
+
IotaMoveNormalizedModule,
|
76
|
+
IotaEvent | IotaMoveObject
|
77
|
+
> {
|
78
|
+
timestamp: Date
|
79
|
+
checkpoint: bigint
|
80
|
+
coder: MoveCoder
|
81
|
+
txDigest: string
|
82
|
+
|
83
|
+
constructor(
|
84
|
+
network: IotaNetwork,
|
85
|
+
address: string,
|
86
|
+
timestamp: Date,
|
87
|
+
checkpoint: bigint,
|
88
|
+
txDigest: string,
|
89
|
+
baseLabels: Labels | undefined
|
90
|
+
) {
|
91
|
+
super(baseLabels)
|
92
|
+
this.address = address
|
93
|
+
this.network = network
|
94
|
+
this.timestamp = timestamp
|
95
|
+
this.checkpoint = checkpoint
|
96
|
+
this.txDigest = txDigest
|
97
|
+
this.coder = defaultMoveCoder(network)
|
98
|
+
}
|
99
|
+
|
100
|
+
getChainId() {
|
101
|
+
return this.network
|
102
|
+
}
|
103
|
+
|
104
|
+
getTimestamp(): number {
|
105
|
+
return this.timestamp.getDate()
|
106
|
+
}
|
107
|
+
|
108
|
+
getMetaDataInternal(name: string, labels: Labels): RecordMetaData {
|
109
|
+
return {
|
110
|
+
address: this.address,
|
111
|
+
contractName: '*',
|
112
|
+
blockNumber: this.checkpoint,
|
113
|
+
transactionIndex: -1,
|
114
|
+
transactionHash: this.txDigest,
|
115
|
+
logIndex: 0,
|
116
|
+
chainId: this.getChainId(),
|
117
|
+
name: name,
|
118
|
+
labels: normalizeLabels(labels)
|
119
|
+
}
|
120
|
+
}
|
121
|
+
|
122
|
+
get client(): IotaClient {
|
123
|
+
return getClient(this.network)
|
124
|
+
}
|
125
|
+
}
|
126
|
+
|
127
|
+
// TODO address handler should use this context
|
128
|
+
export class IotaAddressContext extends MoveAccountContext<
|
129
|
+
IotaNetwork,
|
130
|
+
IotaMoveNormalizedModule,
|
131
|
+
IotaEvent | IotaMoveObject
|
132
|
+
> {
|
133
|
+
address: string
|
134
|
+
network: IotaNetwork
|
135
|
+
checkpoint: bigint
|
136
|
+
timestamp: Date
|
137
|
+
coder: MoveCoder
|
138
|
+
|
139
|
+
protected contractName = 'address'
|
140
|
+
|
141
|
+
constructor(
|
142
|
+
network: IotaNetwork,
|
143
|
+
address: string,
|
144
|
+
checkpoint: bigint,
|
145
|
+
timestamp: Date,
|
146
|
+
baseLabels: Labels | undefined
|
147
|
+
) {
|
148
|
+
super(baseLabels)
|
149
|
+
this.address = address
|
150
|
+
this.network = network
|
151
|
+
this.checkpoint = checkpoint
|
152
|
+
this.timestamp = timestamp
|
153
|
+
this.coder = defaultMoveCoder(network)
|
154
|
+
}
|
155
|
+
|
156
|
+
getChainId() {
|
157
|
+
return this.network
|
158
|
+
}
|
159
|
+
|
160
|
+
getMetaDataInternal(name: string, labels: Labels): RecordMetaData {
|
161
|
+
return {
|
162
|
+
address: this.address,
|
163
|
+
contractName: this.contractName,
|
164
|
+
blockNumber: this.checkpoint,
|
165
|
+
transactionIndex: 0,
|
166
|
+
transactionHash: '',
|
167
|
+
logIndex: 0,
|
168
|
+
chainId: this.getChainId(),
|
169
|
+
name: name,
|
170
|
+
labels: normalizeLabels(labels)
|
171
|
+
}
|
172
|
+
}
|
173
|
+
|
174
|
+
get client(): IotaClient {
|
175
|
+
return getClient(this.network)
|
176
|
+
}
|
177
|
+
|
178
|
+
getTimestamp(): number {
|
179
|
+
return this.timestamp.getDate()
|
180
|
+
}
|
181
|
+
}
|
182
|
+
|
183
|
+
export class IotaObjectContext extends IotaAddressContext {
|
184
|
+
contractName = 'object'
|
185
|
+
objectId: string
|
186
|
+
objectVersion: bigint
|
187
|
+
|
188
|
+
constructor(
|
189
|
+
network: IotaNetwork,
|
190
|
+
objectId: string,
|
191
|
+
objectVersion: bigint,
|
192
|
+
checkpoint: bigint,
|
193
|
+
timestamp: Date,
|
194
|
+
baseLabels: Labels | undefined
|
195
|
+
) {
|
196
|
+
super(network, objectId, checkpoint, timestamp, baseLabels)
|
197
|
+
this.objectId = objectId
|
198
|
+
this.objectVersion = objectVersion
|
199
|
+
}
|
200
|
+
}
|