@lukso/transaction-decoder 1.0.1-dev.0f1bea5
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/LICENSE +201 -0
- package/README.md +486 -0
- package/dist/browser.cjs +6912 -0
- package/dist/browser.cjs.map +1 -0
- package/dist/browser.d.cts +6 -0
- package/dist/browser.d.ts +6 -0
- package/dist/browser.js +131 -0
- package/dist/browser.js.map +1 -0
- package/dist/cdn/transaction-decoder.global.js +296 -0
- package/dist/cdn/transaction-decoder.global.js.map +1 -0
- package/dist/chunk-GGBHTWJL.js +437 -0
- package/dist/chunk-GGBHTWJL.js.map +1 -0
- package/dist/chunk-GXZOF3QY.js +839 -0
- package/dist/chunk-GXZOF3QY.js.map +1 -0
- package/dist/chunk-LJ6ES5XF.js +776 -0
- package/dist/chunk-LJ6ES5XF.js.map +1 -0
- package/dist/chunk-XVHJWV5U.js +4925 -0
- package/dist/chunk-XVHJWV5U.js.map +1 -0
- package/dist/data.cjs +5518 -0
- package/dist/data.cjs.map +1 -0
- package/dist/data.d.cts +43 -0
- package/dist/data.d.ts +43 -0
- package/dist/data.js +55 -0
- package/dist/data.js.map +1 -0
- package/dist/index-BzXh7poJ.d.cts +524 -0
- package/dist/index-BzXh7poJ.d.ts +524 -0
- package/dist/index.cjs +6912 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +756 -0
- package/dist/index.d.ts +756 -0
- package/dist/index.js +131 -0
- package/dist/index.js.map +1 -0
- package/dist/server.cjs +5644 -0
- package/dist/server.cjs.map +1 -0
- package/dist/server.d.cts +217 -0
- package/dist/server.d.ts +217 -0
- package/dist/server.js +644 -0
- package/dist/server.js.map +1 -0
- package/dist/utils-CBAkjQh3.d.cts +108 -0
- package/dist/utils-xT9-km0r.d.ts +108 -0
- package/package.json +101 -0
- package/src/browser.ts +13 -0
- package/src/client/resolveAddresses.ts +157 -0
- package/src/core/addressCollector.ts +153 -0
- package/src/core/addressResolver.ts +135 -0
- package/src/core/dataModel.ts +888 -0
- package/src/core/instance.ts +33 -0
- package/src/core/integrateDecoder.ts +325 -0
- package/src/data.ts +70 -0
- package/src/decoder/GENERATOR_PROPOSAL.md +182 -0
- package/src/decoder/THREE_PHASE_EXAMPLE.md +108 -0
- package/src/decoder/aggregation.ts +218 -0
- package/src/decoder/browserCache.ts +237 -0
- package/src/decoder/cache/README.md +126 -0
- package/src/decoder/cache/index.ts +44 -0
- package/src/decoder/cache.ts +139 -0
- package/src/decoder/constants.ts +125 -0
- package/src/decoder/decodeTransaction.ts +292 -0
- package/src/decoder/errors.ts +95 -0
- package/src/decoder/events.ts +192 -0
- package/src/decoder/functionSignature.ts +344 -0
- package/src/decoder/getDataFromExternalSources.ts +248 -0
- package/src/decoder/graphqlWS.ts +22 -0
- package/src/decoder/interfaces.ts +185 -0
- package/src/decoder/keyValue.ts +5 -0
- package/src/decoder/kvCache.ts +241 -0
- package/src/decoder/lruCache.ts +184 -0
- package/src/decoder/lsp7Mint.test.ts +179 -0
- package/src/decoder/lsp7TransferBatch.test.ts +105 -0
- package/src/decoder/plugins/RegistryAbi.ts +562 -0
- package/src/decoder/plugins/enhanceBurntPix.ts +132 -0
- package/src/decoder/plugins/enhanceGraffiti.ts +70 -0
- package/src/decoder/plugins/enhanceLSP0ERC725Account.ts +179 -0
- package/src/decoder/plugins/enhanceLSP26FollowerSystem.ts +88 -0
- package/src/decoder/plugins/enhanceLSP6KeyManager.ts +231 -0
- package/src/decoder/plugins/enhanceLSP7DigitalAsset.ts +165 -0
- package/src/decoder/plugins/enhanceLSP8IdentifiableDigitalAsset.ts +170 -0
- package/src/decoder/plugins/enhanceLSP9Vault.ts +57 -0
- package/src/decoder/plugins/enhanceRetrieveAbi.ts +85 -0
- package/src/decoder/plugins/enhanceSetData.ts +135 -0
- package/src/decoder/plugins/index.ts +99 -0
- package/src/decoder/plugins/schemaDefault.ts +318 -0
- package/src/decoder/plugins/standardPlugin.ts +202 -0
- package/src/decoder/registry.ts +322 -0
- package/src/decoder/singleGQL.ts +293 -0
- package/src/decoder/transaction.ts +198 -0
- package/src/decoder/types.ts +465 -0
- package/src/decoder/utils.ts +212 -0
- package/src/example/usage.ts +172 -0
- package/src/index.ts +174 -0
- package/src/server/addressResolver.ts +68 -0
- package/src/server/caches.ts +209 -0
- package/src/server/decodeTransactionSync.ts +156 -0
- package/src/server/decodeTransactionsBatch.ts +207 -0
- package/src/server/finishDecoding.ts +116 -0
- package/src/server/index.ts +81 -0
- package/src/server/lsp23Resolver.test.ts +46 -0
- package/src/server/lsp23Resolver.ts +419 -0
- package/src/server/types.ts +168 -0
- package/src/server.ts +22 -0
- package/src/shared/addressResolver.ts +651 -0
- package/src/shared/cache.ts +144 -0
- package/src/shared/constants.ts +21 -0
- package/src/stubs/tty.ts +13 -0
- package/src/stubs/util.ts +42 -0
- package/src/types/index.ts +154 -0
- package/src/types/provider.ts +46 -0
- package/src/umd.ts +13 -0
- package/src/utils/debug.ts +49 -0
- package/src/utils/json-bigint.ts +47 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type AbiParameter,
|
|
3
|
+
bytesToString,
|
|
4
|
+
type Hex,
|
|
5
|
+
hexToBytes,
|
|
6
|
+
size,
|
|
7
|
+
slice,
|
|
8
|
+
} from 'viem'
|
|
9
|
+
import type {
|
|
10
|
+
DecodeEventResult,
|
|
11
|
+
DecoderOptions,
|
|
12
|
+
DecoderPlugin,
|
|
13
|
+
DecoderResult,
|
|
14
|
+
PluginOptions,
|
|
15
|
+
ResultType,
|
|
16
|
+
} from '../types'
|
|
17
|
+
|
|
18
|
+
// Since this plugin doesn't use an abi, we need to short circuit with "as DecoderResult"
|
|
19
|
+
export const enhanceGraffitiPlugin: DecoderPlugin = Object.freeze({
|
|
20
|
+
enhance: async (result: DecoderResult, options: DecoderOptions) =>
|
|
21
|
+
enhanceGraffiti(
|
|
22
|
+
result,
|
|
23
|
+
{ abiName: 'graffiti', decoderName: 'graffiti' },
|
|
24
|
+
options
|
|
25
|
+
),
|
|
26
|
+
decodeEvent: async (log: DecodeEventResult, options: DecoderOptions) =>
|
|
27
|
+
undefined,
|
|
28
|
+
required: true,
|
|
29
|
+
priority: 1000,
|
|
30
|
+
name: 'graffiti',
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
export async function enhanceGraffiti(
|
|
34
|
+
result: DecoderResult,
|
|
35
|
+
_pluginOptions: PluginOptions,
|
|
36
|
+
_options: DecoderOptions
|
|
37
|
+
) {
|
|
38
|
+
const { functionName, sig, args, input } = result as ResultType & {
|
|
39
|
+
sig?: `0x${string}`
|
|
40
|
+
functionName?: string
|
|
41
|
+
args: Array<AbiParameter & { value?: unknown }>
|
|
42
|
+
namedArgs?:
|
|
43
|
+
| Record<number, AbiParameter & { value?: unknown }>
|
|
44
|
+
| Record<string, unknown>
|
|
45
|
+
}
|
|
46
|
+
if (
|
|
47
|
+
input &&
|
|
48
|
+
size(input || '0x') >= 4 &&
|
|
49
|
+
slice(input || '0x', 0, 4) === '0x00000000'
|
|
50
|
+
) {
|
|
51
|
+
let graffiti: string = slice(input, 4)
|
|
52
|
+
try {
|
|
53
|
+
graffiti = bytesToString(hexToBytes(graffiti as Hex))
|
|
54
|
+
} catch {
|
|
55
|
+
// Ignore
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
...result,
|
|
59
|
+
resultType: 'grafitti',
|
|
60
|
+
sig: '0x',
|
|
61
|
+
functionName: '',
|
|
62
|
+
input,
|
|
63
|
+
graffiti,
|
|
64
|
+
__decoder: 'grafitti',
|
|
65
|
+
} as DecoderResult
|
|
66
|
+
}
|
|
67
|
+
return undefined
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export default enhanceGraffitiPlugin
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { universalProfileAbi as UniversalProfile } from '@lukso/universalprofile-contracts/abi'
|
|
2
|
+
import type { Address } from 'viem'
|
|
3
|
+
import { decodeEvent } from '../events'
|
|
4
|
+
import { decodeTransaction } from '../transaction'
|
|
5
|
+
import type {
|
|
6
|
+
ArrayArgs,
|
|
7
|
+
DecodeEventResult,
|
|
8
|
+
DecoderOptions,
|
|
9
|
+
DecoderResult,
|
|
10
|
+
PluginOptions,
|
|
11
|
+
ResultExecute,
|
|
12
|
+
ResultShared,
|
|
13
|
+
ResultType,
|
|
14
|
+
} from '../types'
|
|
15
|
+
import { createNamedArgs } from '../utils'
|
|
16
|
+
import { standardPlugin } from '.'
|
|
17
|
+
import { enhanceSetData } from './enhanceSetData'
|
|
18
|
+
|
|
19
|
+
export const enhanceLSP0ERC725AccountPlugin = standardPlugin(
|
|
20
|
+
UniversalProfile,
|
|
21
|
+
{
|
|
22
|
+
name: 'profile',
|
|
23
|
+
abiName: 'LSP0ERC725Account',
|
|
24
|
+
decoderName: '@lukso/lsp-smart-contracts',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
enhance: enhanceLSP0ERC725Account,
|
|
28
|
+
decodeEvent: async (log: DecodeEventResult, options: DecoderOptions) => {
|
|
29
|
+
return decodeEvent(options.chain, UniversalProfile, log)
|
|
30
|
+
},
|
|
31
|
+
}
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
export async function enhanceLSP0ERC725Account(
|
|
35
|
+
result: DecoderResult,
|
|
36
|
+
pluginOptions: PluginOptions,
|
|
37
|
+
options: DecoderOptions
|
|
38
|
+
): Promise<DecoderResult | undefined> {
|
|
39
|
+
const setData = await enhanceSetData(
|
|
40
|
+
result,
|
|
41
|
+
{ ...pluginOptions, abiName: '', decoderName: '' },
|
|
42
|
+
options
|
|
43
|
+
)
|
|
44
|
+
if (setData) {
|
|
45
|
+
return setData
|
|
46
|
+
}
|
|
47
|
+
const {
|
|
48
|
+
functionName,
|
|
49
|
+
sig,
|
|
50
|
+
args,
|
|
51
|
+
input,
|
|
52
|
+
blockNumber,
|
|
53
|
+
to: _to,
|
|
54
|
+
from: _from,
|
|
55
|
+
value,
|
|
56
|
+
} = result as ResultType & {
|
|
57
|
+
sig?: `0x${string}`
|
|
58
|
+
functionName?: string
|
|
59
|
+
args: ArrayArgs
|
|
60
|
+
}
|
|
61
|
+
let to = _to
|
|
62
|
+
let from = _from
|
|
63
|
+
switch (functionName) {
|
|
64
|
+
case 'executeBatch': {
|
|
65
|
+
// executeBatch
|
|
66
|
+
const children: Array<ResultType> = []
|
|
67
|
+
const [executeTypes, targets, values, inputs] = args.map(
|
|
68
|
+
({ value }) => value
|
|
69
|
+
) as [bigint[], Address[], bigint[], `0x${string}`[]]
|
|
70
|
+
const {
|
|
71
|
+
functionName: _functionName,
|
|
72
|
+
sig: _sig,
|
|
73
|
+
args: _args,
|
|
74
|
+
resultType: _resultType,
|
|
75
|
+
...plainResult
|
|
76
|
+
} = result as ResultExecute & ResultShared
|
|
77
|
+
for (let i = 0; i < values.length; i++) {
|
|
78
|
+
const _data = inputs[i] as `0x${string}`
|
|
79
|
+
const _value = BigInt(values[i])
|
|
80
|
+
const _to = targets[i]
|
|
81
|
+
const decoded = await decodeTransaction(
|
|
82
|
+
{
|
|
83
|
+
input: _data,
|
|
84
|
+
to: _to,
|
|
85
|
+
from: from,
|
|
86
|
+
value: _value,
|
|
87
|
+
} as DecoderResult,
|
|
88
|
+
options
|
|
89
|
+
)
|
|
90
|
+
children.push(
|
|
91
|
+
executeTypes[i] === 1n
|
|
92
|
+
? ({
|
|
93
|
+
...plainResult,
|
|
94
|
+
...decoded,
|
|
95
|
+
resultType: 'create',
|
|
96
|
+
} as DecoderResult)
|
|
97
|
+
: ({ ...plainResult, ...decoded } as DecoderResult)
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
options.wrappers.splice(0, 0, {
|
|
101
|
+
...result,
|
|
102
|
+
resultType: 'wrapper',
|
|
103
|
+
functionName,
|
|
104
|
+
sig,
|
|
105
|
+
standard: pluginOptions.abiName,
|
|
106
|
+
args,
|
|
107
|
+
to,
|
|
108
|
+
from,
|
|
109
|
+
value,
|
|
110
|
+
input,
|
|
111
|
+
__decoder: pluginOptions.decoderName,
|
|
112
|
+
} as DecoderResult)
|
|
113
|
+
const execute: ResultType = {
|
|
114
|
+
...result,
|
|
115
|
+
resultType: 'executeBatch',
|
|
116
|
+
standard: pluginOptions.abiName,
|
|
117
|
+
__decoder: pluginOptions.decoderName,
|
|
118
|
+
children,
|
|
119
|
+
to,
|
|
120
|
+
from,
|
|
121
|
+
value,
|
|
122
|
+
} as unknown as ResultType
|
|
123
|
+
return {
|
|
124
|
+
blockNumber,
|
|
125
|
+
...execute,
|
|
126
|
+
} as unknown as DecoderResult
|
|
127
|
+
}
|
|
128
|
+
case 'execute': {
|
|
129
|
+
// LSP0 execute
|
|
130
|
+
const [executeType, target, value, _data] = args.map(
|
|
131
|
+
({ value }) => value
|
|
132
|
+
) as [bigint, Address, bigint, `0x${string}`]
|
|
133
|
+
// const _target = await getKMTarget(chain, to)
|
|
134
|
+
const decoded = await decodeTransaction(
|
|
135
|
+
{
|
|
136
|
+
input: _data,
|
|
137
|
+
to: target,
|
|
138
|
+
from: to || from, // This should be decoded to the profile address if it's a controller.
|
|
139
|
+
value,
|
|
140
|
+
} as DecoderResult,
|
|
141
|
+
options
|
|
142
|
+
)
|
|
143
|
+
from = to || from
|
|
144
|
+
to = target || to
|
|
145
|
+
options.wrappers?.splice(0, 0, {
|
|
146
|
+
...result,
|
|
147
|
+
resultType: 'wrapper',
|
|
148
|
+
functionName,
|
|
149
|
+
sig,
|
|
150
|
+
input,
|
|
151
|
+
__decoder: pluginOptions.decoderName,
|
|
152
|
+
to,
|
|
153
|
+
from,
|
|
154
|
+
value,
|
|
155
|
+
standard: pluginOptions.abiName,
|
|
156
|
+
...createNamedArgs(
|
|
157
|
+
[executeType, target, value, _data],
|
|
158
|
+
[
|
|
159
|
+
{ name: 'executeType', type: 'uint256' },
|
|
160
|
+
{ name: 'target', type: 'address' },
|
|
161
|
+
{ name: 'value', type: 'uint256' },
|
|
162
|
+
{ name: 'data', type: 'bytes' },
|
|
163
|
+
]
|
|
164
|
+
),
|
|
165
|
+
} as DecoderResult)
|
|
166
|
+
return {
|
|
167
|
+
...result,
|
|
168
|
+
functionName,
|
|
169
|
+
sig,
|
|
170
|
+
standard: pluginOptions.abiName,
|
|
171
|
+
__decoder: pluginOptions.decoderName,
|
|
172
|
+
...decoded,
|
|
173
|
+
resultType: executeType === 1n ? 'create' : 'execute',
|
|
174
|
+
} as unknown as DecoderResult
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export default enhanceLSP0ERC725AccountPlugin
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { lsp26FollowerSystemAbi as LSP26 } from '@lukso/lsp26-contracts/abi'
|
|
2
|
+
import type { AbiParameter, Address } from 'viem'
|
|
3
|
+
import { decodeEvent } from '../events'
|
|
4
|
+
import type {
|
|
5
|
+
DecodeEventResult,
|
|
6
|
+
DecoderOptions,
|
|
7
|
+
DecoderResult,
|
|
8
|
+
PluginOptions,
|
|
9
|
+
ResultExecute,
|
|
10
|
+
ResultType,
|
|
11
|
+
} from '../types'
|
|
12
|
+
import { standardPlugin } from '.'
|
|
13
|
+
import { enhanceSetData } from './enhanceSetData'
|
|
14
|
+
|
|
15
|
+
export const enhanceLSP26FollowerSystemPlugin = standardPlugin(
|
|
16
|
+
LSP26,
|
|
17
|
+
{
|
|
18
|
+
name: 'lsp26',
|
|
19
|
+
abiName: 'LSP26FollowerSystem',
|
|
20
|
+
decoderName: '@lukso/lsp-smart-contracts',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
enhance: async (result, pluginOptions, options) => {
|
|
24
|
+
const setData = await enhanceSetData(result, pluginOptions, options)
|
|
25
|
+
if (setData) {
|
|
26
|
+
return setData
|
|
27
|
+
}
|
|
28
|
+
return await enhanceLSP26FollowerSystem(result, pluginOptions, options)
|
|
29
|
+
},
|
|
30
|
+
decodeEvent: async (log: DecodeEventResult, options: DecoderOptions) => {
|
|
31
|
+
return decodeEvent(options.chain, LSP26, log)
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
|
+
)
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* @param result enhanced if it's LSP8
|
|
38
|
+
* @param pluginOptions
|
|
39
|
+
* @param options
|
|
40
|
+
* @returns
|
|
41
|
+
*/
|
|
42
|
+
export async function enhanceLSP26FollowerSystem(
|
|
43
|
+
result: DecoderResult,
|
|
44
|
+
_pluginOptions: PluginOptions,
|
|
45
|
+
_options: DecoderOptions
|
|
46
|
+
) {
|
|
47
|
+
const { functionName, sig, args, input, blockNumber, to, from, value } =
|
|
48
|
+
result as ResultType & {
|
|
49
|
+
sig?: `0x${string}`
|
|
50
|
+
functionName?: string
|
|
51
|
+
args: Array<AbiParameter & { value?: unknown }>
|
|
52
|
+
}
|
|
53
|
+
const { args: _args, ...partialResult } = result as ResultExecute
|
|
54
|
+
switch (functionName) {
|
|
55
|
+
case 'follow':
|
|
56
|
+
case 'unfollow':
|
|
57
|
+
return {
|
|
58
|
+
...result,
|
|
59
|
+
children: [
|
|
60
|
+
{
|
|
61
|
+
...partialResult,
|
|
62
|
+
resultType: 'followProfile',
|
|
63
|
+
phase: 'enhanced',
|
|
64
|
+
address: args[0]?.value as Address,
|
|
65
|
+
} as DecoderResult,
|
|
66
|
+
],
|
|
67
|
+
} as DecoderResult
|
|
68
|
+
break
|
|
69
|
+
case 'followBatch':
|
|
70
|
+
case 'unfollowBatch':
|
|
71
|
+
return {
|
|
72
|
+
...result,
|
|
73
|
+
children: (result.resultType === 'execute'
|
|
74
|
+
? (result.args?.[0]?.value as Array<Address>) || []
|
|
75
|
+
: []
|
|
76
|
+
).map((address: Address) => ({
|
|
77
|
+
...partialResult,
|
|
78
|
+
phase: 'enhanced',
|
|
79
|
+
resultType: 'followProfile',
|
|
80
|
+
address,
|
|
81
|
+
})),
|
|
82
|
+
} as DecoderResult
|
|
83
|
+
break
|
|
84
|
+
}
|
|
85
|
+
return undefined
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export default enhanceLSP26FollowerSystemPlugin
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { lsp6KeyManagerAbi as KeyManager } from '@lukso/lsp6-contracts/abi'
|
|
2
|
+
import type { AbiParameter } from 'viem'
|
|
3
|
+
import { decodeEvent } from '../events'
|
|
4
|
+
import { getKMTarget } from '../interfaces'
|
|
5
|
+
import { decodeTransaction } from '../transaction'
|
|
6
|
+
import type {
|
|
7
|
+
DecodeEventResult,
|
|
8
|
+
DecoderOptions,
|
|
9
|
+
DecoderResult,
|
|
10
|
+
PluginOptions,
|
|
11
|
+
ResultExecute,
|
|
12
|
+
ResultShared,
|
|
13
|
+
ResultType,
|
|
14
|
+
} from '../types'
|
|
15
|
+
import { standardPlugin } from '.'
|
|
16
|
+
import { enhanceSetData } from './enhanceSetData'
|
|
17
|
+
|
|
18
|
+
export const enhanceLSP6KeyManagerPlugin = standardPlugin(
|
|
19
|
+
KeyManager,
|
|
20
|
+
{
|
|
21
|
+
name: 'keyManager',
|
|
22
|
+
abiName: 'LSP6KeyManager',
|
|
23
|
+
decoderName: '@lukso/lsp-smart-contracts',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
enhance: async (result, pluginOptions, options) => {
|
|
27
|
+
const setData = await enhanceSetData(result, pluginOptions, options)
|
|
28
|
+
if (setData) {
|
|
29
|
+
return setData
|
|
30
|
+
}
|
|
31
|
+
return enhanceKeyManager(result, pluginOptions, options)
|
|
32
|
+
},
|
|
33
|
+
decodeEvent: async (log: DecodeEventResult, options: DecoderOptions) => {
|
|
34
|
+
return decodeEvent(options.chain, KeyManager, log)
|
|
35
|
+
},
|
|
36
|
+
}
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
export async function enhanceKeyManager(
|
|
40
|
+
result: ResultType & ResultShared & { moduleHint?: string },
|
|
41
|
+
pluginOptions: PluginOptions,
|
|
42
|
+
options: DecoderOptions
|
|
43
|
+
): Promise<DecoderResult | undefined> {
|
|
44
|
+
const {
|
|
45
|
+
functionName,
|
|
46
|
+
sig,
|
|
47
|
+
args,
|
|
48
|
+
input,
|
|
49
|
+
blockNumber,
|
|
50
|
+
to: _to,
|
|
51
|
+
from: _from,
|
|
52
|
+
value,
|
|
53
|
+
} = result as ResultType & {
|
|
54
|
+
sig?: `0x${string}`
|
|
55
|
+
functionName?: string
|
|
56
|
+
args: Array<AbiParameter & { value?: unknown }>
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
let to = _to
|
|
60
|
+
let from = _from
|
|
61
|
+
|
|
62
|
+
switch (functionName) {
|
|
63
|
+
case 'execute': {
|
|
64
|
+
// LSP6 execute
|
|
65
|
+
const decoded = await decodeTransaction(
|
|
66
|
+
{
|
|
67
|
+
input: args?.[0]?.value as `0x${string}` | undefined,
|
|
68
|
+
to,
|
|
69
|
+
from,
|
|
70
|
+
value,
|
|
71
|
+
} as DecoderResult,
|
|
72
|
+
options
|
|
73
|
+
)
|
|
74
|
+
options.wrappers?.splice(0, 0, {
|
|
75
|
+
...result,
|
|
76
|
+
resultType: 'wrapper',
|
|
77
|
+
__decoder: pluginOptions.decoderName,
|
|
78
|
+
functionName,
|
|
79
|
+
sig,
|
|
80
|
+
input,
|
|
81
|
+
standard: pluginOptions.abiName,
|
|
82
|
+
args,
|
|
83
|
+
} as DecoderResult)
|
|
84
|
+
const execute: ResultType = {
|
|
85
|
+
...result,
|
|
86
|
+
...decoded,
|
|
87
|
+
to,
|
|
88
|
+
from,
|
|
89
|
+
value,
|
|
90
|
+
} as unknown as ResultType
|
|
91
|
+
return {
|
|
92
|
+
...execute,
|
|
93
|
+
} as unknown as DecoderResult
|
|
94
|
+
}
|
|
95
|
+
case 'executeBatch': {
|
|
96
|
+
// LSP6 executeBatch
|
|
97
|
+
const children: Array<ResultType> = []
|
|
98
|
+
const [values, inputs] = args.map(({ value }) => value) as [
|
|
99
|
+
`0x${string}`[],
|
|
100
|
+
`0x${string}`[],
|
|
101
|
+
]
|
|
102
|
+
const {
|
|
103
|
+
functionName: _functionName,
|
|
104
|
+
sig: _sig,
|
|
105
|
+
args: _args,
|
|
106
|
+
resultType: _resultType,
|
|
107
|
+
...plainResult
|
|
108
|
+
} = result as ResultExecute & ResultShared
|
|
109
|
+
|
|
110
|
+
for (let i = 0; i < values.length; i++) {
|
|
111
|
+
const _data = inputs[i] as `0x${string}`
|
|
112
|
+
const _value = BigInt(values[i])
|
|
113
|
+
const decoded = await decodeTransaction(
|
|
114
|
+
{
|
|
115
|
+
input: _data,
|
|
116
|
+
to,
|
|
117
|
+
from,
|
|
118
|
+
value: _value,
|
|
119
|
+
} as DecoderResult,
|
|
120
|
+
options
|
|
121
|
+
)
|
|
122
|
+
children.push({ ...plainResult, ...decoded } as DecoderResult)
|
|
123
|
+
}
|
|
124
|
+
options.wrappers?.splice(0, 0, {
|
|
125
|
+
...result,
|
|
126
|
+
resultType: 'wrapper',
|
|
127
|
+
functionName,
|
|
128
|
+
sig,
|
|
129
|
+
__decoder: pluginOptions.decoderName,
|
|
130
|
+
standard: pluginOptions.abiName,
|
|
131
|
+
args,
|
|
132
|
+
input,
|
|
133
|
+
} as DecoderResult)
|
|
134
|
+
return {
|
|
135
|
+
...result,
|
|
136
|
+
resultType: 'executeBatch',
|
|
137
|
+
__decoder: '@lukso/lsp-smart-contracts',
|
|
138
|
+
standard: pluginOptions.abiName,
|
|
139
|
+
children,
|
|
140
|
+
to,
|
|
141
|
+
from,
|
|
142
|
+
value,
|
|
143
|
+
} as unknown as DecoderResult
|
|
144
|
+
}
|
|
145
|
+
case 'executeRelayerCallBatch': {
|
|
146
|
+
// executeRelayerCallBatch
|
|
147
|
+
const [signatures, nonces, validityTimestamps, values, payloads] =
|
|
148
|
+
args.map(({ value }) => value) as [
|
|
149
|
+
`0x${string}`[],
|
|
150
|
+
bigint[],
|
|
151
|
+
bigint[],
|
|
152
|
+
bigint[],
|
|
153
|
+
`0x${string}`[],
|
|
154
|
+
]
|
|
155
|
+
const children: Array<ResultType> = []
|
|
156
|
+
for (let i = 0; i < values.length; i++) {
|
|
157
|
+
const _data = payloads[i] as `0x${string}`
|
|
158
|
+
const _value = BigInt(values[i])
|
|
159
|
+
const _signature = signatures[i] as `0x${string}`
|
|
160
|
+
const _nonce = nonces[i]
|
|
161
|
+
const _validityTimestamp = validityTimestamps[i]
|
|
162
|
+
const decoded = await decodeTransaction(
|
|
163
|
+
{
|
|
164
|
+
input: _data,
|
|
165
|
+
to,
|
|
166
|
+
from,
|
|
167
|
+
value: _value,
|
|
168
|
+
} as DecoderResult,
|
|
169
|
+
options
|
|
170
|
+
)
|
|
171
|
+
children.push({ ...result, ...decoded } as DecoderResult)
|
|
172
|
+
}
|
|
173
|
+
options.wrappers?.splice(0, 0, {
|
|
174
|
+
...result,
|
|
175
|
+
resultType: 'wrapper',
|
|
176
|
+
__decoder: pluginOptions.decoderName,
|
|
177
|
+
functionName,
|
|
178
|
+
sig,
|
|
179
|
+
input,
|
|
180
|
+
standard: pluginOptions.abiName,
|
|
181
|
+
args,
|
|
182
|
+
} as DecoderResult)
|
|
183
|
+
return {
|
|
184
|
+
...result,
|
|
185
|
+
resultType: 'executeBatch',
|
|
186
|
+
__decoder: pluginOptions.decoderName,
|
|
187
|
+
standard: pluginOptions.abiName,
|
|
188
|
+
children,
|
|
189
|
+
to,
|
|
190
|
+
from,
|
|
191
|
+
value,
|
|
192
|
+
} as unknown as DecoderResult
|
|
193
|
+
}
|
|
194
|
+
// -> executeRelayCall
|
|
195
|
+
case 'executeRelayCall': {
|
|
196
|
+
const [_signature, _nonce, _validityTimestamps, _input] = args.map(
|
|
197
|
+
({ value }) => value
|
|
198
|
+
) as [`0x${string}`, bigint, bigint, `0x${string}`]
|
|
199
|
+
const _target = await getKMTarget(options.chain, to)
|
|
200
|
+
const decoded = await decodeTransaction(
|
|
201
|
+
{
|
|
202
|
+
input: _input,
|
|
203
|
+
to: _target ?? to,
|
|
204
|
+
from,
|
|
205
|
+
value,
|
|
206
|
+
} as DecoderResult,
|
|
207
|
+
options
|
|
208
|
+
)
|
|
209
|
+
from = to || from
|
|
210
|
+
to = _target || to
|
|
211
|
+
options.wrappers?.splice(0, 0, {
|
|
212
|
+
...result,
|
|
213
|
+
resultType: 'wrapper',
|
|
214
|
+
__decoder: pluginOptions.decoderName,
|
|
215
|
+
functionName,
|
|
216
|
+
sig,
|
|
217
|
+
input,
|
|
218
|
+
standard: pluginOptions.abiName,
|
|
219
|
+
to,
|
|
220
|
+
from,
|
|
221
|
+
value,
|
|
222
|
+
args,
|
|
223
|
+
} as DecoderResult)
|
|
224
|
+
return {
|
|
225
|
+
...decoded,
|
|
226
|
+
} as unknown as DecoderResult
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export default enhanceLSP6KeyManagerPlugin
|