@effectstream/sm 0.100.0
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/Stm.ts +88 -0
- package/delegate-wallet.ts +431 -0
- package/mod.ts +4 -0
- package/package.json +27 -0
- package/primitives/Primitive.ts +80 -0
- package/primitives/PrimitiveRegistry.ts +59 -0
- package/primitives/mod.ts +5 -0
- package/primitives/processing.ts +72 -0
- package/primitives/src/README.md +3 -0
- package/primitives/src/avail-generic/avail-generic-grammar.ts +5 -0
- package/primitives/src/avail-generic/avail-primitive.ts +103 -0
- package/primitives/src/bitcoin-address/bitcoin-grammar.ts +16 -0
- package/primitives/src/bitcoin-address/bitcoin-primitive.ts +113 -0
- package/primitives/src/builtin.ts +47 -0
- package/primitives/src/celestia-generic/celestia-generic-grammar.ts +5 -0
- package/primitives/src/celestia-generic/celestia-primitive.ts +97 -0
- package/primitives/src/evm-effectstream-l2/effectstream-l2-abi.ts +1 -0
- package/primitives/src/evm-effectstream-l2/effectstream-l2-primitive.ts +484 -0
- package/primitives/src/evm-erc1155/erc1155-abi.ts +1 -0
- package/primitives/src/evm-erc1155/erc1155-grammar.ts +13 -0
- package/primitives/src/evm-erc1155/erc1155-ivm.ts +104 -0
- package/primitives/src/evm-erc1155/erc1155-primitive.ts +242 -0
- package/primitives/src/evm-erc20/erc20-abi.ts +1 -0
- package/primitives/src/evm-erc20/erc20-grammar.ts +7 -0
- package/primitives/src/evm-erc20/erc20-ivm.ts +93 -0
- package/primitives/src/evm-erc20/erc20-primitive.test.ts +123 -0
- package/primitives/src/evm-erc20/erc20-primitive.ts +152 -0
- package/primitives/src/evm-erc721/erc721-abi.ts +1 -0
- package/primitives/src/evm-erc721/erc721-grammar.ts +9 -0
- package/primitives/src/evm-erc721/erc721-ivm.ts +85 -0
- package/primitives/src/evm-erc721/erc721-primitive.ts +149 -0
- package/primitives/src/evm-generic/evm-generic-primitive.ts +124 -0
- package/primitives/src/grammar.ts +34 -0
- package/primitives/src/midnight-generic/midnight-genetic-grammar.ts +8 -0
- package/primitives/src/midnight-generic/midnight-genetic.ts +271 -0
- package/primitives/src/midnight-nullifier/midnight-nullifier-grammar.ts +8 -0
- package/primitives/src/midnight-nullifier/midnight-nullifier.ts +114 -0
- package/primitives/src/mod.ts +81 -0
- package/primitives/src/near-account-watch/near-account-watch-grammar.ts +10 -0
- package/primitives/src/near-account-watch/near-account-watch-primitive.ts +106 -0
- package/primitives/src/near-generic/near-generic-grammar.ts +5 -0
- package/primitives/src/near-generic/near-generic-primitive.ts +105 -0
- package/primitives/src/near-intent/near-intent-grammar.ts +10 -0
- package/primitives/src/near-intent/near-intent-ivm.ts +71 -0
- package/primitives/src/near-intent/near-intent-primitive.ts +149 -0
- package/primitives/src/near-intent/near-intent-token-id-parser.ts +47 -0
- package/primitives/src/near-nep141/nep141-grammar.ts +7 -0
- package/primitives/src/near-nep141/nep141-ivm.ts +70 -0
- package/primitives/src/near-nep141/nep141-primitive.ts +117 -0
- package/primitives/src/near-nep171/nep171-grammar.ts +8 -0
- package/primitives/src/near-nep171/nep171-ivm.ts +71 -0
- package/primitives/src/near-nep171/nep171-primitive.ts +138 -0
- package/primitives/src/near-nep245/nep245-grammar.ts +11 -0
- package/primitives/src/near-nep245/nep245-ivm.ts +84 -0
- package/primitives/src/near-nep245/nep245-primitive.ts +147 -0
- package/primitives/src/utxorpc-generic/utxorpc-generic-grammar.ts +6 -0
- package/primitives/src/utxorpc-generic/utxorpc-generic.ts +88 -0
- package/primitives/types.ts +14 -0
- package/types.ts +28 -0
- package/verify-signature.ts +51 -0
|
@@ -0,0 +1,484 @@
|
|
|
1
|
+
import { getEvmEvent } from "@effectstream/config";
|
|
2
|
+
import {
|
|
3
|
+
type AddressAndType,
|
|
4
|
+
AddressType,
|
|
5
|
+
type BlockNumber,
|
|
6
|
+
type EvmAddress,
|
|
7
|
+
type EffectstreamBlockNumber,
|
|
8
|
+
type TxHash,
|
|
9
|
+
TypeboxHelpers,
|
|
10
|
+
type WalletAddress,
|
|
11
|
+
} from "@effectstream/utils";
|
|
12
|
+
import { type Signature } from "@effectstream/utils";
|
|
13
|
+
import { hexToString, stringToHex } from "viem";
|
|
14
|
+
import type {
|
|
15
|
+
ConfigSyncProtocolType,
|
|
16
|
+
FlattenSyncProtocolIOFor,
|
|
17
|
+
ProtocolPrimitiveMap,
|
|
18
|
+
} from "@effectstream/config";
|
|
19
|
+
import type { StateUpdateStream } from "@effectstream/coroutine";
|
|
20
|
+
import {
|
|
21
|
+
findNonce,
|
|
22
|
+
getAddressByAddress,
|
|
23
|
+
insertNonce,
|
|
24
|
+
newAddress,
|
|
25
|
+
} from "@effectstream/db";
|
|
26
|
+
import { World } from "@effectstream/coroutine";
|
|
27
|
+
import {
|
|
28
|
+
createMessageForBatcher,
|
|
29
|
+
extractBatches,
|
|
30
|
+
extractDelegateWallet,
|
|
31
|
+
type ExtractedBatchSubunit,
|
|
32
|
+
type GrammarDefinition,
|
|
33
|
+
} from "@effectstream/concise";
|
|
34
|
+
import { CryptoManager } from "@effectstream/crypto";
|
|
35
|
+
import { ComponentNames, log, SeverityNumber } from "@effectstream/log";
|
|
36
|
+
import {
|
|
37
|
+
account_createAccount,
|
|
38
|
+
account_linkAddress,
|
|
39
|
+
account_unlinkAddress,
|
|
40
|
+
} from "@effectstream/sm";
|
|
41
|
+
import { BuiltinGrammarPrefix } from "@effectstream/concise";
|
|
42
|
+
|
|
43
|
+
import { effectstreamL2 } from "./effectstream-l2-abi.ts";
|
|
44
|
+
import { type StaticDecode, type TSchema, Type } from "@sinclair/typebox";
|
|
45
|
+
import { type JsonObject, Primitive } from "@effectstream/sm";
|
|
46
|
+
import { Value } from "@sinclair/typebox/value";
|
|
47
|
+
import type { CommandTuple } from "@effectstream/concise";
|
|
48
|
+
import { PrimitiveTypeEVMEffectstreamL2 } from "../builtin.ts";
|
|
49
|
+
|
|
50
|
+
export class EffectstreamL2Primitive extends Primitive<
|
|
51
|
+
ConfigSyncProtocolType.EVM_RPC_PARALLEL,
|
|
52
|
+
readonly [string, TSchema][]
|
|
53
|
+
> {
|
|
54
|
+
// Primitive defined
|
|
55
|
+
readonly internalTypeName = PrimitiveTypeEVMEffectstreamL2;
|
|
56
|
+
readonly abi = getEvmEvent(
|
|
57
|
+
effectstreamL2.abi,
|
|
58
|
+
"EffectstreamGameInteraction(address,bytes,uint256)",
|
|
59
|
+
);
|
|
60
|
+
readonly contractAddress: EvmAddress;
|
|
61
|
+
override grammar = [];
|
|
62
|
+
readonly effectstreamL2Grammar: GrammarDefinition;
|
|
63
|
+
|
|
64
|
+
constructor(config: {
|
|
65
|
+
instanceName: string;
|
|
66
|
+
startBlockHeight: number;
|
|
67
|
+
contractAddress: EvmAddress;
|
|
68
|
+
effectstreamL2Grammar: GrammarDefinition;
|
|
69
|
+
}) {
|
|
70
|
+
super({ ...config, stateMachinePrefix: undefined });
|
|
71
|
+
this.contractAddress = Value.Decode(
|
|
72
|
+
TypeboxHelpers.Evm.Address,
|
|
73
|
+
config.contractAddress,
|
|
74
|
+
);
|
|
75
|
+
this.effectstreamL2Grammar = config.effectstreamL2Grammar;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
override *getPayload(
|
|
79
|
+
effectstream_block_height: EffectstreamBlockNumber,
|
|
80
|
+
primitiveTransactionData: FlattenSyncProtocolIOFor<
|
|
81
|
+
ConfigSyncProtocolType.EVM_RPC_PARALLEL
|
|
82
|
+
>,
|
|
83
|
+
): StateUpdateStream<{
|
|
84
|
+
isBatched: boolean;
|
|
85
|
+
data: {
|
|
86
|
+
fromAddressAndType: AddressAndType;
|
|
87
|
+
stateMachinePayload:
|
|
88
|
+
| StaticDecode<
|
|
89
|
+
CommandTuple<string, any>
|
|
90
|
+
>
|
|
91
|
+
| null;
|
|
92
|
+
accountingPayload: JsonObject;
|
|
93
|
+
}[];
|
|
94
|
+
}> {
|
|
95
|
+
const { data, isBatched } = yield* this.processEffectstreamL2SyncProtocolResponse(
|
|
96
|
+
effectstream_block_height,
|
|
97
|
+
primitiveTransactionData,
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
const dataPayload = data
|
|
101
|
+
.filter(({ command }) => command)
|
|
102
|
+
.map(({ command, callSTM, fromAddressAndType }) => {
|
|
103
|
+
const concise = JSON.parse(command as string);
|
|
104
|
+
return {
|
|
105
|
+
fromAddressAndType,
|
|
106
|
+
accountingPayload: concise,
|
|
107
|
+
stateMachinePayload: callSTM ? concise : null,
|
|
108
|
+
};
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
isBatched,
|
|
113
|
+
data: dataPayload,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
override getConfig(): ProtocolPrimitiveMap[
|
|
118
|
+
ConfigSyncProtocolType.EVM_RPC_PARALLEL
|
|
119
|
+
] {
|
|
120
|
+
return {
|
|
121
|
+
name: this.instanceName,
|
|
122
|
+
type: this.internalTypeName,
|
|
123
|
+
startBlockHeight: this.startBlockHeight,
|
|
124
|
+
contractAddress: this.contractAddress as EvmAddress,
|
|
125
|
+
abi: this.abi,
|
|
126
|
+
// TODO This should be optional.
|
|
127
|
+
scheduledPrefix: this.stateMachinePrefix ?? "",
|
|
128
|
+
} as const;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
private *checkNonce(
|
|
132
|
+
nonce: string | undefined,
|
|
133
|
+
block_height: BlockNumber,
|
|
134
|
+
): StateUpdateStream<boolean> {
|
|
135
|
+
// TODO This is only for batched messages?
|
|
136
|
+
if (!nonce) return true;
|
|
137
|
+
|
|
138
|
+
const [nonceData] = yield* World.resolve(findNonce, { nonce });
|
|
139
|
+
if (nonceData) {
|
|
140
|
+
log.remote(
|
|
141
|
+
ComponentNames.EFFECTSTREAM_SYNC,
|
|
142
|
+
["effectstream-l2"],
|
|
143
|
+
SeverityNumber.INFO,
|
|
144
|
+
(log) =>
|
|
145
|
+
log(
|
|
146
|
+
`Skipping inputData with duplicate nonce: ${nonceData.nonce} at block height: ${nonceData.block_height}`,
|
|
147
|
+
),
|
|
148
|
+
);
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
// guarantee we run this no matter if there is an error or a continue
|
|
152
|
+
yield* World.resolve(insertNonce, {
|
|
153
|
+
nonce,
|
|
154
|
+
block_height,
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
private readonly PrimitiveEvmRpcEffectstreamL2Payload = Type.Object({
|
|
161
|
+
userAddress: TypeboxHelpers.Evm.Address,
|
|
162
|
+
data: TypeboxHelpers.HexString0x(),
|
|
163
|
+
value: TypeboxHelpers.Uint256,
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
private readonly EffectstreamL2Payload = Type.Object({
|
|
167
|
+
userAddress: Type.String(),
|
|
168
|
+
data: Type.String(),
|
|
169
|
+
value: Type.String({ default: "0" }),
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* NOTE: if "command" is undefined, it means the input is invalid and must be skipped as it does not exist.
|
|
174
|
+
* if "callSTM" is false, it means the input is valid, but the contents are invalid, and it will be stored in the accounting, but not processed in the STF.
|
|
175
|
+
*/
|
|
176
|
+
private *executeEffectstreamL2Input(input: {
|
|
177
|
+
effectstream_block_height: EffectstreamBlockNumber;
|
|
178
|
+
nonce: string | undefined;
|
|
179
|
+
ownChain: {
|
|
180
|
+
blockNumber: BlockNumber;
|
|
181
|
+
transactionHash: TxHash;
|
|
182
|
+
};
|
|
183
|
+
payload: any;
|
|
184
|
+
primitiveName: string;
|
|
185
|
+
signerAddressAndType: AddressAndType;
|
|
186
|
+
}): StateUpdateStream<{
|
|
187
|
+
command: string | undefined;
|
|
188
|
+
callSTM: boolean;
|
|
189
|
+
fromAddressAndType: AddressAndType;
|
|
190
|
+
}> {
|
|
191
|
+
const isNonceValid = yield* this.checkNonce(
|
|
192
|
+
input.nonce,
|
|
193
|
+
input.effectstream_block_height,
|
|
194
|
+
);
|
|
195
|
+
if (!isNonceValid) {
|
|
196
|
+
return {
|
|
197
|
+
command: undefined,
|
|
198
|
+
callSTM: false,
|
|
199
|
+
fromAddressAndType: input.signerAddressAndType,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
try {
|
|
204
|
+
Value.Decode(this.EffectstreamL2Payload, input.payload);
|
|
205
|
+
} catch (e) {
|
|
206
|
+
log.remote(
|
|
207
|
+
ComponentNames.EFFECTSTREAM_SYNC,
|
|
208
|
+
["effectstream-l2"],
|
|
209
|
+
SeverityNumber.ERROR,
|
|
210
|
+
(log) =>
|
|
211
|
+
log(
|
|
212
|
+
`Invalid payload: ${e}\nPayload: ${JSON.stringify(input.payload)}`,
|
|
213
|
+
),
|
|
214
|
+
);
|
|
215
|
+
return {
|
|
216
|
+
command: undefined,
|
|
217
|
+
callSTM: false,
|
|
218
|
+
fromAddressAndType: { type: AddressType.NONE, address: "0x0" },
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// This is encoded in the event payload data.
|
|
223
|
+
// NOTE: We cleanup the null 0x00 bytes, as Postgres does not allow them in strings.
|
|
224
|
+
const inputData = hexToString((input.payload as any).data).replace(
|
|
225
|
+
/\0/g,
|
|
226
|
+
"",
|
|
227
|
+
);
|
|
228
|
+
|
|
229
|
+
let [signer_address] = yield* World.resolve(getAddressByAddress, {
|
|
230
|
+
address: input.signerAddressAndType.address,
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
if (!signer_address) {
|
|
234
|
+
// Let's insert a new address.
|
|
235
|
+
yield* World.resolve(newAddress, {
|
|
236
|
+
address: input.signerAddressAndType.address,
|
|
237
|
+
address_type: input.signerAddressAndType.type,
|
|
238
|
+
});
|
|
239
|
+
[signer_address] = yield* World.resolve(getAddressByAddress, {
|
|
240
|
+
address: input.signerAddressAndType.address,
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
let delegateWalletInputData:
|
|
245
|
+
| ReturnType<typeof extractDelegateWallet>
|
|
246
|
+
| undefined;
|
|
247
|
+
try {
|
|
248
|
+
delegateWalletInputData = extractDelegateWallet(inputData);
|
|
249
|
+
} catch {
|
|
250
|
+
// This is not an error, it's not just a delegate wallet message type.
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (delegateWalletInputData) {
|
|
254
|
+
try {
|
|
255
|
+
let status = false;
|
|
256
|
+
const delegatePrefix = delegateWalletInputData.prefix;
|
|
257
|
+
switch (delegatePrefix) {
|
|
258
|
+
case BuiltinGrammarPrefix.createAccount:
|
|
259
|
+
status = yield* account_createAccount(
|
|
260
|
+
signer_address,
|
|
261
|
+
delegateWalletInputData,
|
|
262
|
+
);
|
|
263
|
+
break;
|
|
264
|
+
case BuiltinGrammarPrefix.linkAddress:
|
|
265
|
+
status = yield* account_linkAddress(
|
|
266
|
+
signer_address,
|
|
267
|
+
delegateWalletInputData,
|
|
268
|
+
);
|
|
269
|
+
break;
|
|
270
|
+
case BuiltinGrammarPrefix.unlinkAddress:
|
|
271
|
+
status = yield* account_unlinkAddress(
|
|
272
|
+
signer_address,
|
|
273
|
+
delegateWalletInputData,
|
|
274
|
+
);
|
|
275
|
+
break;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
if (!status) {
|
|
279
|
+
log.remote(
|
|
280
|
+
ComponentNames.EFFECTSTREAM_SYNC,
|
|
281
|
+
["effectstream-l2"],
|
|
282
|
+
SeverityNumber.ERROR,
|
|
283
|
+
(log) =>
|
|
284
|
+
log(
|
|
285
|
+
`[effectstream-sm] Error on Delegate Wallet input STF call. Skipping: ` +
|
|
286
|
+
delegateWalletInputData,
|
|
287
|
+
),
|
|
288
|
+
);
|
|
289
|
+
// Do not continue.
|
|
290
|
+
// Unwind is not needed, as this is an format error.
|
|
291
|
+
return {
|
|
292
|
+
command: inputData,
|
|
293
|
+
callSTM: false,
|
|
294
|
+
fromAddressAndType: input.signerAddressAndType,
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
// If valid we continue to create a scheduled data,
|
|
298
|
+
// if the developer want to capture it and do something with it.
|
|
299
|
+
} catch (e) {
|
|
300
|
+
// This is not an error, it's not just a delegate wallet message type.
|
|
301
|
+
console.error(
|
|
302
|
+
"Error on Delegate Wallet input STF call. Skipping",
|
|
303
|
+
String(e),
|
|
304
|
+
delegateWalletInputData,
|
|
305
|
+
);
|
|
306
|
+
return {
|
|
307
|
+
command: inputData,
|
|
308
|
+
callSTM: false,
|
|
309
|
+
fromAddressAndType: input.signerAddressAndType,
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
console.log(
|
|
315
|
+
"Creating scheduled data for Effectstream L2 input",
|
|
316
|
+
inputData,
|
|
317
|
+
input.effectstream_block_height,
|
|
318
|
+
input.primitiveName,
|
|
319
|
+
input.ownChain.transactionHash,
|
|
320
|
+
signer_address.address,
|
|
321
|
+
);
|
|
322
|
+
|
|
323
|
+
return {
|
|
324
|
+
command: inputData,
|
|
325
|
+
callSTM: true,
|
|
326
|
+
fromAddressAndType: input.signerAddressAndType,
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
private *processEffectstreamL2SyncProtocolResponse(
|
|
331
|
+
effectstream_block_height: EffectstreamBlockNumber,
|
|
332
|
+
response: FlattenSyncProtocolIOFor<
|
|
333
|
+
ConfigSyncProtocolType.EVM_RPC_PARALLEL
|
|
334
|
+
>,
|
|
335
|
+
): StateUpdateStream<{
|
|
336
|
+
data: {
|
|
337
|
+
command: string | undefined;
|
|
338
|
+
callSTM: boolean;
|
|
339
|
+
fromAddressAndType: AddressAndType;
|
|
340
|
+
}[];
|
|
341
|
+
isBatched: boolean;
|
|
342
|
+
}> {
|
|
343
|
+
// At this point we have the response from the fetcher, but the payload has not been decoded or transformed.
|
|
344
|
+
const commands: {
|
|
345
|
+
command: string | undefined;
|
|
346
|
+
callSTM: boolean;
|
|
347
|
+
fromAddressAndType: AddressAndType;
|
|
348
|
+
}[] = [];
|
|
349
|
+
const outerLayerData = Value.Decode(
|
|
350
|
+
this.PrimitiveEvmRpcEffectstreamL2Payload,
|
|
351
|
+
response.output.payload,
|
|
352
|
+
);
|
|
353
|
+
let isBatched = false;
|
|
354
|
+
let batchedMessages: ExtractedBatchSubunit[] = [];
|
|
355
|
+
try {
|
|
356
|
+
const message = hexToString(outerLayerData.data);
|
|
357
|
+
batchedMessages = extractBatches(message);
|
|
358
|
+
isBatched = true;
|
|
359
|
+
} catch {
|
|
360
|
+
// Not batched message
|
|
361
|
+
}
|
|
362
|
+
if (isBatched) {
|
|
363
|
+
for (const batchedMessage of batchedMessages) {
|
|
364
|
+
const { parsed } = batchedMessage;
|
|
365
|
+
const {
|
|
366
|
+
addressType,
|
|
367
|
+
address: userAddress,
|
|
368
|
+
timestamp: millisecondTimestamp,
|
|
369
|
+
signature: userSignature,
|
|
370
|
+
input: conciseInput,
|
|
371
|
+
target: batcherTarget,
|
|
372
|
+
} = parsed;
|
|
373
|
+
// TODO: We need to setup & configure the namespace.
|
|
374
|
+
const message = createMessageForBatcher(
|
|
375
|
+
null,
|
|
376
|
+
millisecondTimestamp,
|
|
377
|
+
userAddress,
|
|
378
|
+
addressType,
|
|
379
|
+
conciseInput,
|
|
380
|
+
batcherTarget,
|
|
381
|
+
);
|
|
382
|
+
// We yield the promise to the generator caller.
|
|
383
|
+
// Sync Generators cannot resolve promises.
|
|
384
|
+
const validSignature = yield* verifySignature(
|
|
385
|
+
addressType,
|
|
386
|
+
userAddress,
|
|
387
|
+
message,
|
|
388
|
+
userSignature,
|
|
389
|
+
);
|
|
390
|
+
|
|
391
|
+
const cryptoManager = CryptoManager.getCryptoManager(addressType);
|
|
392
|
+
const signerAddress = cryptoManager.decodeAddress(userAddress);
|
|
393
|
+
|
|
394
|
+
if (validSignature) {
|
|
395
|
+
commands.push(
|
|
396
|
+
yield* this.executeEffectstreamL2Input({
|
|
397
|
+
effectstream_block_height,
|
|
398
|
+
nonce: batchedMessage.parsed.address +
|
|
399
|
+
"-" +
|
|
400
|
+
batchedMessage.parsed.timestamp,
|
|
401
|
+
ownChain: {
|
|
402
|
+
blockNumber: response.syncProtocol.blockNumber,
|
|
403
|
+
transactionHash: response.syncProtocol.transactionHash,
|
|
404
|
+
},
|
|
405
|
+
payload: {
|
|
406
|
+
data: stringToHex(batchedMessage.parsed.input),
|
|
407
|
+
userAddress: userAddress as EvmAddress, // This might be a non-EVM address
|
|
408
|
+
value: "0x0",
|
|
409
|
+
},
|
|
410
|
+
primitiveName: response.primitive,
|
|
411
|
+
signerAddressAndType: {
|
|
412
|
+
type: addressType,
|
|
413
|
+
address: signerAddress,
|
|
414
|
+
} as AddressAndType,
|
|
415
|
+
}),
|
|
416
|
+
);
|
|
417
|
+
} else {
|
|
418
|
+
commands.push({
|
|
419
|
+
command: undefined,
|
|
420
|
+
callSTM: false,
|
|
421
|
+
fromAddressAndType: {
|
|
422
|
+
type: addressType,
|
|
423
|
+
address: signerAddress,
|
|
424
|
+
} as AddressAndType,
|
|
425
|
+
});
|
|
426
|
+
log.remote(
|
|
427
|
+
ComponentNames.EFFECTSTREAM_SYNC,
|
|
428
|
+
["effectstream-l2"],
|
|
429
|
+
SeverityNumber.ERROR,
|
|
430
|
+
(log) => log(`Invalid signature for batched message`),
|
|
431
|
+
);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
} else {
|
|
435
|
+
// !isBatched
|
|
436
|
+
// This is a EVM contract, so the signer is always EVM.
|
|
437
|
+
const signerAddress: EvmAddress = CryptoManager.getCryptoManager(AddressType.EVM).decodeAddress(outerLayerData.userAddress) as EvmAddress;
|
|
438
|
+
commands.push(
|
|
439
|
+
yield* this.executeEffectstreamL2Input({
|
|
440
|
+
effectstream_block_height,
|
|
441
|
+
// TODO: where do we get the nonce from?
|
|
442
|
+
nonce: undefined,
|
|
443
|
+
ownChain: {
|
|
444
|
+
blockNumber: response.syncProtocol.blockNumber,
|
|
445
|
+
transactionHash: response.syncProtocol.transactionHash,
|
|
446
|
+
},
|
|
447
|
+
payload: outerLayerData,
|
|
448
|
+
primitiveName: response.primitive,
|
|
449
|
+
signerAddressAndType: {
|
|
450
|
+
type: AddressType.EVM,
|
|
451
|
+
address: signerAddress,
|
|
452
|
+
},
|
|
453
|
+
}),
|
|
454
|
+
);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
return {
|
|
458
|
+
data: commands,
|
|
459
|
+
isBatched,
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
function* verifySignature(
|
|
465
|
+
addressType: AddressType,
|
|
466
|
+
address: WalletAddress,
|
|
467
|
+
message: string,
|
|
468
|
+
signature: Signature
|
|
469
|
+
): StateUpdateStream<boolean> {
|
|
470
|
+
try {
|
|
471
|
+
const cryptoManager = CryptoManager.getCryptoManager(addressType);
|
|
472
|
+
return yield* World.promise(
|
|
473
|
+
cryptoManager.verifySignature(address, message, signature)
|
|
474
|
+
);
|
|
475
|
+
} catch (error) {
|
|
476
|
+
return false;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
// declare module "@effectstream/sm" {
|
|
481
|
+
// interface PrimitiveGlobalDefinitions {
|
|
482
|
+
// EffectstreamL2Primitive: typeof EffectstreamL2Primitive;
|
|
483
|
+
// }
|
|
484
|
+
// }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const erc1155 = {"abi":[{"type":"function","name":"balanceOf","inputs":[{"name":"account","type":"address","internalType":"address"},{"name":"id","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"balanceOfBatch","inputs":[{"name":"accounts","type":"address[]","internalType":"address[]"},{"name":"ids","type":"uint256[]","internalType":"uint256[]"}],"outputs":[{"name":"","type":"uint256[]","internalType":"uint256[]"}],"stateMutability":"view"},{"type":"function","name":"isApprovedForAll","inputs":[{"name":"account","type":"address","internalType":"address"},{"name":"operator","type":"address","internalType":"address"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"safeBatchTransferFrom","inputs":[{"name":"from","type":"address","internalType":"address"},{"name":"to","type":"address","internalType":"address"},{"name":"ids","type":"uint256[]","internalType":"uint256[]"},{"name":"values","type":"uint256[]","internalType":"uint256[]"},{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"safeTransferFrom","inputs":[{"name":"from","type":"address","internalType":"address"},{"name":"to","type":"address","internalType":"address"},{"name":"id","type":"uint256","internalType":"uint256"},{"name":"value","type":"uint256","internalType":"uint256"},{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setApprovalForAll","inputs":[{"name":"operator","type":"address","internalType":"address"},{"name":"approved","type":"bool","internalType":"bool"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"supportsInterface","inputs":[{"name":"interfaceId","type":"bytes4","internalType":"bytes4"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"uri","inputs":[{"name":"","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"view"},{"type":"event","name":"ApprovalForAll","inputs":[{"name":"account","type":"address","indexed":true,"internalType":"address"},{"name":"operator","type":"address","indexed":true,"internalType":"address"},{"name":"approved","type":"bool","indexed":false,"internalType":"bool"}],"anonymous":false},{"type":"event","name":"TransferBatch","inputs":[{"name":"operator","type":"address","indexed":true,"internalType":"address"},{"name":"from","type":"address","indexed":true,"internalType":"address"},{"name":"to","type":"address","indexed":true,"internalType":"address"},{"name":"ids","type":"uint256[]","indexed":false,"internalType":"uint256[]"},{"name":"values","type":"uint256[]","indexed":false,"internalType":"uint256[]"}],"anonymous":false},{"type":"event","name":"TransferSingle","inputs":[{"name":"operator","type":"address","indexed":true,"internalType":"address"},{"name":"from","type":"address","indexed":true,"internalType":"address"},{"name":"to","type":"address","indexed":true,"internalType":"address"},{"name":"id","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"value","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false},{"type":"event","name":"URI","inputs":[{"name":"value","type":"string","indexed":false,"internalType":"string"},{"name":"id","type":"uint256","indexed":true,"internalType":"uint256"}],"anonymous":false},{"type":"error","name":"ERC1155InsufficientBalance","inputs":[{"name":"sender","type":"address","internalType":"address"},{"name":"balance","type":"uint256","internalType":"uint256"},{"name":"needed","type":"uint256","internalType":"uint256"},{"name":"tokenId","type":"uint256","internalType":"uint256"}]},{"type":"error","name":"ERC1155InvalidApprover","inputs":[{"name":"approver","type":"address","internalType":"address"}]},{"type":"error","name":"ERC1155InvalidArrayLength","inputs":[{"name":"idsLength","type":"uint256","internalType":"uint256"},{"name":"valuesLength","type":"uint256","internalType":"uint256"}]},{"type":"error","name":"ERC1155InvalidOperator","inputs":[{"name":"operator","type":"address","internalType":"address"}]},{"type":"error","name":"ERC1155InvalidReceiver","inputs":[{"name":"receiver","type":"address","internalType":"address"}]},{"type":"error","name":"ERC1155InvalidSender","inputs":[{"name":"sender","type":"address","internalType":"address"}]},{"type":"error","name":"ERC1155MissingApprovalForAll","inputs":[{"name":"operator","type":"address","internalType":"address"},{"name":"owner","type":"address","internalType":"address"}]}],"bytecode":{"object":"0x","sourceMap":"","linkReferences":{}},"deployedBytecode":{"object":"0x","sourceMap":"","linkReferences":{}},"methodIdentifiers":{"balanceOf(address,uint256)":"00fdd58e","balanceOfBatch(address[],uint256[])":"4e1273f4","isApprovedForAll(address,address)":"e985e9c5","safeBatchTransferFrom(address,address,uint256[],uint256[],bytes)":"2eb2c2d6","safeTransferFrom(address,address,uint256,uint256,bytes)":"f242432a","setApprovalForAll(address,bool)":"a22cb465","supportsInterface(bytes4)":"01ffc9a7","uri(uint256)":"0e89341c"},"rawMetadata":"{\"compiler\":{\"version\":\"0.8.30+commit.73712a01\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"needed\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"ERC1155InsufficientBalance\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"approver\",\"type\":\"address\"}],\"name\":\"ERC1155InvalidApprover\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"idsLength\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"valuesLength\",\"type\":\"uint256\"}],\"name\":\"ERC1155InvalidArrayLength\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"}],\"name\":\"ERC1155InvalidOperator\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"}],\"name\":\"ERC1155InvalidReceiver\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"ERC1155InvalidSender\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"ERC1155MissingApprovalForAll\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"}],\"name\":\"ApprovalForAll\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"ids\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"values\",\"type\":\"uint256[]\"}],\"name\":\"TransferBatch\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"TransferSingle\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"string\",\"name\":\"value\",\"type\":\"string\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"}],\"name\":\"URI\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"accounts\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"ids\",\"type\":\"uint256[]\"}],\"name\":\"balanceOfBatch\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"}],\"name\":\"isApprovedForAll\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256[]\",\"name\":\"ids\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256[]\",\"name\":\"values\",\"type\":\"uint256[]\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"safeBatchTransferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"safeTransferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"}],\"name\":\"setApprovalForAll\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"uri\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Implementation of the basic standard multi-token. See https://eips.ethereum.org/EIPS/eip-1155 Originally based on code by Enjin: https://github.com/enjin/erc-1155\",\"errors\":{\"ERC1155InsufficientBalance(address,uint256,uint256,uint256)\":[{\"details\":\"Indicates an error related to the current `balance` of a `sender`. Used in transfers.\",\"params\":{\"balance\":\"Current balance for the interacting account.\",\"needed\":\"Minimum amount required to perform a transfer.\",\"sender\":\"Address whose tokens are being transferred.\",\"tokenId\":\"Identifier number of a token.\"}}],\"ERC1155InvalidApprover(address)\":[{\"details\":\"Indicates a failure with the `approver` of a token to be approved. Used in approvals.\",\"params\":{\"approver\":\"Address initiating an approval operation.\"}}],\"ERC1155InvalidArrayLength(uint256,uint256)\":[{\"details\":\"Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation. Used in batch transfers.\",\"params\":{\"idsLength\":\"Length of the array of token identifiers\",\"valuesLength\":\"Length of the array of token amounts\"}}],\"ERC1155InvalidOperator(address)\":[{\"details\":\"Indicates a failure with the `operator` to be approved. Used in approvals.\",\"params\":{\"operator\":\"Address that may be allowed to operate on tokens without being their owner.\"}}],\"ERC1155InvalidReceiver(address)\":[{\"details\":\"Indicates a failure with the token `receiver`. Used in transfers.\",\"params\":{\"receiver\":\"Address to which tokens are being transferred.\"}}],\"ERC1155InvalidSender(address)\":[{\"details\":\"Indicates a failure with the token `sender`. Used in transfers.\",\"params\":{\"sender\":\"Address whose tokens are being transferred.\"}}],\"ERC1155MissingApprovalForAll(address,address)\":[{\"details\":\"Indicates a failure with the `operator`\\u2019s approval. Used in transfers.\",\"params\":{\"operator\":\"Address that may be allowed to operate on tokens without being their owner.\",\"owner\":\"Address of the current owner of a token.\"}}]},\"events\":{\"ApprovalForAll(address,address,bool)\":{\"details\":\"Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to `approved`.\"},\"TransferBatch(address,address,address,uint256[],uint256[])\":{\"details\":\"Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all transfers.\"},\"TransferSingle(address,address,address,uint256,uint256)\":{\"details\":\"Emitted when `value` amount of tokens of type `id` are transferred from `from` to `to` by `operator`.\"},\"URI(string,uint256)\":{\"details\":\"Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. If an {URI} event was emitted for `id`, the standard https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value returned by {IERC1155MetadataURI-uri}.\"}},\"kind\":\"dev\",\"methods\":{\"balanceOf(address,uint256)\":{\"details\":\"See {IERC1155-balanceOf}.\"},\"balanceOfBatch(address[],uint256[])\":{\"details\":\"See {IERC1155-balanceOfBatch}. Requirements: - `accounts` and `ids` must have the same length.\"},\"constructor\":{\"details\":\"See {_setURI}.\"},\"isApprovedForAll(address,address)\":{\"details\":\"See {IERC1155-isApprovedForAll}.\"},\"safeBatchTransferFrom(address,address,uint256[],uint256[],bytes)\":{\"details\":\"See {IERC1155-safeBatchTransferFrom}.\"},\"safeTransferFrom(address,address,uint256,uint256,bytes)\":{\"details\":\"See {IERC1155-safeTransferFrom}.\"},\"setApprovalForAll(address,bool)\":{\"details\":\"See {IERC1155-setApprovalForAll}.\"},\"supportsInterface(bytes4)\":{\"details\":\"See {IERC165-supportsInterface}.\"},\"uri(uint256)\":{\"details\":\"See {IERC1155MetadataURI-uri}. This implementation returns the same URI for *all* token types. It relies on the token type ID substitution mechanism https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the ERC]. Clients calling this function must replace the `\\\\{id\\\\}` substring with the actual token type ID.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"../../../../node_modules/@openzeppelin/contracts/token/ERC1155/ERC1155.sol\":\"ERC1155\"},\"evmVersion\":\"berlin\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[\":@openzeppelin/=../../../../node_modules/@openzeppelin/\",\":@paimaexample/=../../../../node_modules/@paimaexample/\"]},\"sources\":{\"../../../../node_modules/@openzeppelin/contracts/interfaces/draft-IERC6093.sol\":{\"keccak256\":\"0x880da465c203cec76b10d72dbd87c80f387df4102274f23eea1f9c9b0918792b\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://399594cd8bb0143bc9e55e0f1d071d0d8c850a394fb7a319d50edd55d9ed822b\",\"dweb:/ipfs/QmbPZzgtT6LEm9CMqWfagQFwETbV1ztpECBB1DtQHrKiRz\"]},\"../../../../node_modules/@openzeppelin/contracts/token/ERC1155/ERC1155.sol\":{\"keccak256\":\"0x22933f0f4897ff70a991c3baebfbc2574fd052dc4bae7fcafec45b07c1f23dd3\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://13674cffad18cec55f013056496d7d2e3a34bd7bdbe23d1ef0c7588088c73367\",\"dweb:/ipfs/QmcBkrwxNvCApG48Gyby2L6qCNtuhaFncGpbJt3zuukTmu\"]},\"../../../../node_modules/@openzeppelin/contracts/token/ERC1155/IERC1155.sol\":{\"keccak256\":\"0x68d6fdbeb467192c3627a46aa7bf5cbb73267363b740abc511f521a5a41a446e\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://7ce608c19d5e917c60f9c8aa3e5f0eb05b326280ac0a235e8bb9a848a3a64a91\",\"dweb:/ipfs/QmdLPsWQJj7JvRae8MM13GEo4PBXaEFmD4b4heqcyMJNPG\"]},\"../../../../node_modules/@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol\":{\"keccak256\":\"0x61a23d601c2ab69dd726ac55058604cbda98e1d728ba31a51c379a3f9eeea715\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://d8cbb06152d82ebdd5ba1d33454e5759492040f309a82637c7e99c948a04fa20\",\"dweb:/ipfs/QmQQuLr6WSfLu97pMEh6XLefk99TSj9k5Qu1zXGPepwGiK\"]},\"../../../../node_modules/@openzeppelin/contracts/token/ERC1155/extensions/IERC1155MetadataURI.sol\":{\"keccak256\":\"0x35d120c427299af1525aaf07955314d9e36a62f14408eb93dec71a2e001f74d3\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://743e38acf441eece428c008be399c40a3ca5b2d595d58faf656cbdbac1a45374\",\"dweb:/ipfs/QmcWDuWkndox3dxa5P7ZgpKy3iuQKkxBq1cR9hPV1ZzAfa\"]},\"../../../../node_modules/@openzeppelin/contracts/token/ERC1155/utils/ERC1155Utils.sol\":{\"keccak256\":\"0x30afe9013aaeb3ba735284a9310792776f57a3b2db6fc1d99628f2c47287f5cf\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://1c675b740746031092efcedb2e18179f05fce8ba482de64e982715e4aa16bc90\",\"dweb:/ipfs/QmVdUD89qYudLc88k5AsuQ6VWyz9SE1c6UXrVK32Yqh1YS\"]},\"../../../../node_modules/@openzeppelin/contracts/utils/Arrays.sol\":{\"keccak256\":\"0xaf9586854de33dc9d3a7160cad8170fdfb4119d02a44bad90ba16d71d701cc92\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://c15a02762b0a51d66e36be135c27de656093fc09292fa743df8484b87d4486ea\",\"dweb:/ipfs/QmbEozFrt5XwC9nzDFuXvN1RF3hQVwKYNi8c2R4bFvYJ2X\"]},\"../../../../node_modules/@openzeppelin/contracts/utils/Comparators.sol\":{\"keccak256\":\"0x302eecd8cf323b4690e3494a7d960b3cbce077032ab8ef655b323cdd136cec58\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://49ba706f1bc476d68fe6c1fad75517acea4e9e275be0989b548e292eb3a3eacd\",\"dweb:/ipfs/QmeBpvcdGWzWMKTQESUCEhHgnEQYYATVwPxLMxa6vMT7jC\"]},\"../../../../node_modules/@openzeppelin/contracts/utils/Context.sol\":{\"keccak256\":\"0x493033a8d1b176a037b2cc6a04dad01a5c157722049bbecf632ca876224dd4b2\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://6a708e8a5bdb1011c2c381c9a5cfd8a9a956d7d0a9dc1bd8bcdaf52f76ef2f12\",\"dweb:/ipfs/Qmax9WHBnVsZP46ZxEMNRQpLQnrdE4dK8LehML1Py8FowF\"]},\"../../../../node_modules/@openzeppelin/contracts/utils/Panic.sol\":{\"keccak256\":\"0xf7fe324703a64fc51702311dc51562d5cb1497734f074e4f483bfb6717572d7a\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://c6a5ff4f9fd8649b7ee20800b7fa387d3465bd77cf20c2d1068cd5c98e1ed57a\",\"dweb:/ipfs/QmVSaVJf9FXFhdYEYeCEfjMVHrxDh5qL4CGkxdMWpQCrqG\"]},\"../../../../node_modules/@openzeppelin/contracts/utils/SlotDerivation.sol\":{\"keccak256\":\"0x8447b57b63810fe2e367c09496a966f143ec0e825d71ddb9fce2506cff84b618\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://996cb48f793bf151555045b37138e36b3cdb31d6bc6552d3149285260be00cfb\",\"dweb:/ipfs/QmcLaTTMNVbkMx58xhkp6GeFt4V3GtSyupZuaKG3vYW2Zc\"]},\"../../../../node_modules/@openzeppelin/contracts/utils/StorageSlot.sol\":{\"keccak256\":\"0xcf74f855663ce2ae00ed8352666b7935f6cddea2932fdf2c3ecd30a9b1cd0e97\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://9f660b1f351b757dfe01438e59888f31f33ded3afcf5cb5b0d9bf9aa6f320a8b\",\"dweb:/ipfs/QmarDJ5hZEgBtCmmrVzEZWjub9769eD686jmzb2XpSU1cM\"]},\"../../../../node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\":{\"keccak256\":\"0xddce8e17e3d3f9ed818b4f4c4478a8262aab8b11ed322f1bf5ed705bb4bd97fa\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://8084aa71a4cc7d2980972412a88fe4f114869faea3fefa5436431644eb5c0287\",\"dweb:/ipfs/Qmbqfs5dRdPvHVKY8kTaeyc65NdqXRQwRK7h9s5UJEhD1p\"]},\"../../../../node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\":{\"keccak256\":\"0x79796192ec90263f21b464d5bc90b777a525971d3de8232be80d9c4f9fb353b8\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://f6fda447a62815e8064f47eff0dd1cf58d9207ad69b5d32280f8d7ed1d1e4621\",\"dweb:/ipfs/QmfDRc7pxfaXB2Dh9np5Uf29Na3pQ7tafRS684wd3GLjVL\"]},\"../../../../node_modules/@openzeppelin/contracts/utils/math/Math.sol\":{\"keccak256\":\"0xa00be322d7db5786750ce0ac7e2f5b633ac30a5ed5fa1ced1e74acfc19acecea\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://6c84e822f87cbdc4082533b626667b6928715bb2b1e8e7eb96954cebb9e38c8d\",\"dweb:/ipfs/QmZmy9dgxLTerBAQDuuHqbL6EpgRxddqgv5KmwpXYVbKz1\"]},\"../../../../node_modules/@openzeppelin/contracts/utils/math/SafeCast.sol\":{\"keccak256\":\"0x195533c86d0ef72bcc06456a4f66a9b941f38eb403739b00f21fd7c1abd1ae54\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://b1d578337048cad08c1c03041cca5978eff5428aa130c781b271ad9e5566e1f8\",\"dweb:/ipfs/QmPFKL2r9CBsMwmUqqdcFPfHZB2qcs9g1HDrPxzWSxomvy\"]}},\"version\":1}","metadata":{"compiler":{"version":"0.8.30+commit.73712a01"},"language":"Solidity","output":{"abi":[{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"type":"error","name":"ERC1155InsufficientBalance"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"type":"error","name":"ERC1155InvalidApprover"},{"inputs":[{"internalType":"uint256","name":"idsLength","type":"uint256"},{"internalType":"uint256","name":"valuesLength","type":"uint256"}],"type":"error","name":"ERC1155InvalidArrayLength"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"type":"error","name":"ERC1155InvalidOperator"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"type":"error","name":"ERC1155InvalidReceiver"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"type":"error","name":"ERC1155InvalidSender"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"address","name":"owner","type":"address"}],"type":"error","name":"ERC1155MissingApprovalForAll"},{"inputs":[{"internalType":"address","name":"account","type":"address","indexed":true},{"internalType":"address","name":"operator","type":"address","indexed":true},{"internalType":"bool","name":"approved","type":"bool","indexed":false}],"type":"event","name":"ApprovalForAll","anonymous":false},{"inputs":[{"internalType":"address","name":"operator","type":"address","indexed":true},{"internalType":"address","name":"from","type":"address","indexed":true},{"internalType":"address","name":"to","type":"address","indexed":true},{"internalType":"uint256[]","name":"ids","type":"uint256[]","indexed":false},{"internalType":"uint256[]","name":"values","type":"uint256[]","indexed":false}],"type":"event","name":"TransferBatch","anonymous":false},{"inputs":[{"internalType":"address","name":"operator","type":"address","indexed":true},{"internalType":"address","name":"from","type":"address","indexed":true},{"internalType":"address","name":"to","type":"address","indexed":true},{"internalType":"uint256","name":"id","type":"uint256","indexed":false},{"internalType":"uint256","name":"value","type":"uint256","indexed":false}],"type":"event","name":"TransferSingle","anonymous":false},{"inputs":[{"internalType":"string","name":"value","type":"string","indexed":false},{"internalType":"uint256","name":"id","type":"uint256","indexed":true}],"type":"event","name":"URI","anonymous":false},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"stateMutability":"view","type":"function","name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}]},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"stateMutability":"view","type":"function","name":"balanceOfBatch","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}]},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"stateMutability":"view","type":"function","name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}]},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"stateMutability":"nonpayable","type":"function","name":"safeBatchTransferFrom"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"stateMutability":"nonpayable","type":"function","name":"safeTransferFrom"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"stateMutability":"nonpayable","type":"function","name":"setApprovalForAll"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"stateMutability":"view","type":"function","name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}]},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function","name":"uri","outputs":[{"internalType":"string","name":"","type":"string"}]}],"devdoc":{"kind":"dev","methods":{"balanceOf(address,uint256)":{"details":"See {IERC1155-balanceOf}."},"balanceOfBatch(address[],uint256[])":{"details":"See {IERC1155-balanceOfBatch}. Requirements: - `accounts` and `ids` must have the same length."},"constructor":{"details":"See {_setURI}."},"isApprovedForAll(address,address)":{"details":"See {IERC1155-isApprovedForAll}."},"safeBatchTransferFrom(address,address,uint256[],uint256[],bytes)":{"details":"See {IERC1155-safeBatchTransferFrom}."},"safeTransferFrom(address,address,uint256,uint256,bytes)":{"details":"See {IERC1155-safeTransferFrom}."},"setApprovalForAll(address,bool)":{"details":"See {IERC1155-setApprovalForAll}."},"supportsInterface(bytes4)":{"details":"See {IERC165-supportsInterface}."},"uri(uint256)":{"details":"See {IERC1155MetadataURI-uri}. This implementation returns the same URI for *all* token types. It relies on the token type ID substitution mechanism https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the ERC]. Clients calling this function must replace the `\\{id\\}` substring with the actual token type ID."}},"version":1},"userdoc":{"kind":"user","methods":{},"version":1}},"settings":{"remappings":["@openzeppelin/=../../../../node_modules/@openzeppelin/","@paimaexample/=../../../../node_modules/@paimaexample/"],"optimizer":{"enabled":false,"runs":200},"metadata":{"bytecodeHash":"ipfs"},"compilationTarget":{"../../../../node_modules/@openzeppelin/contracts/token/ERC1155/ERC1155.sol":"ERC1155"},"evmVersion":"berlin","libraries":{}},"sources":{"../../../../node_modules/@openzeppelin/contracts/interfaces/draft-IERC6093.sol":{"keccak256":"0x880da465c203cec76b10d72dbd87c80f387df4102274f23eea1f9c9b0918792b","urls":["bzz-raw://399594cd8bb0143bc9e55e0f1d071d0d8c850a394fb7a319d50edd55d9ed822b","dweb:/ipfs/QmbPZzgtT6LEm9CMqWfagQFwETbV1ztpECBB1DtQHrKiRz"],"license":"MIT"},"../../../../node_modules/@openzeppelin/contracts/token/ERC1155/ERC1155.sol":{"keccak256":"0x22933f0f4897ff70a991c3baebfbc2574fd052dc4bae7fcafec45b07c1f23dd3","urls":["bzz-raw://13674cffad18cec55f013056496d7d2e3a34bd7bdbe23d1ef0c7588088c73367","dweb:/ipfs/QmcBkrwxNvCApG48Gyby2L6qCNtuhaFncGpbJt3zuukTmu"],"license":"MIT"},"../../../../node_modules/@openzeppelin/contracts/token/ERC1155/IERC1155.sol":{"keccak256":"0x68d6fdbeb467192c3627a46aa7bf5cbb73267363b740abc511f521a5a41a446e","urls":["bzz-raw://7ce608c19d5e917c60f9c8aa3e5f0eb05b326280ac0a235e8bb9a848a3a64a91","dweb:/ipfs/QmdLPsWQJj7JvRae8MM13GEo4PBXaEFmD4b4heqcyMJNPG"],"license":"MIT"},"../../../../node_modules/@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol":{"keccak256":"0x61a23d601c2ab69dd726ac55058604cbda98e1d728ba31a51c379a3f9eeea715","urls":["bzz-raw://d8cbb06152d82ebdd5ba1d33454e5759492040f309a82637c7e99c948a04fa20","dweb:/ipfs/QmQQuLr6WSfLu97pMEh6XLefk99TSj9k5Qu1zXGPepwGiK"],"license":"MIT"},"../../../../node_modules/@openzeppelin/contracts/token/ERC1155/extensions/IERC1155MetadataURI.sol":{"keccak256":"0x35d120c427299af1525aaf07955314d9e36a62f14408eb93dec71a2e001f74d3","urls":["bzz-raw://743e38acf441eece428c008be399c40a3ca5b2d595d58faf656cbdbac1a45374","dweb:/ipfs/QmcWDuWkndox3dxa5P7ZgpKy3iuQKkxBq1cR9hPV1ZzAfa"],"license":"MIT"},"../../../../node_modules/@openzeppelin/contracts/token/ERC1155/utils/ERC1155Utils.sol":{"keccak256":"0x30afe9013aaeb3ba735284a9310792776f57a3b2db6fc1d99628f2c47287f5cf","urls":["bzz-raw://1c675b740746031092efcedb2e18179f05fce8ba482de64e982715e4aa16bc90","dweb:/ipfs/QmVdUD89qYudLc88k5AsuQ6VWyz9SE1c6UXrVK32Yqh1YS"],"license":"MIT"},"../../../../node_modules/@openzeppelin/contracts/utils/Arrays.sol":{"keccak256":"0xaf9586854de33dc9d3a7160cad8170fdfb4119d02a44bad90ba16d71d701cc92","urls":["bzz-raw://c15a02762b0a51d66e36be135c27de656093fc09292fa743df8484b87d4486ea","dweb:/ipfs/QmbEozFrt5XwC9nzDFuXvN1RF3hQVwKYNi8c2R4bFvYJ2X"],"license":"MIT"},"../../../../node_modules/@openzeppelin/contracts/utils/Comparators.sol":{"keccak256":"0x302eecd8cf323b4690e3494a7d960b3cbce077032ab8ef655b323cdd136cec58","urls":["bzz-raw://49ba706f1bc476d68fe6c1fad75517acea4e9e275be0989b548e292eb3a3eacd","dweb:/ipfs/QmeBpvcdGWzWMKTQESUCEhHgnEQYYATVwPxLMxa6vMT7jC"],"license":"MIT"},"../../../../node_modules/@openzeppelin/contracts/utils/Context.sol":{"keccak256":"0x493033a8d1b176a037b2cc6a04dad01a5c157722049bbecf632ca876224dd4b2","urls":["bzz-raw://6a708e8a5bdb1011c2c381c9a5cfd8a9a956d7d0a9dc1bd8bcdaf52f76ef2f12","dweb:/ipfs/Qmax9WHBnVsZP46ZxEMNRQpLQnrdE4dK8LehML1Py8FowF"],"license":"MIT"},"../../../../node_modules/@openzeppelin/contracts/utils/Panic.sol":{"keccak256":"0xf7fe324703a64fc51702311dc51562d5cb1497734f074e4f483bfb6717572d7a","urls":["bzz-raw://c6a5ff4f9fd8649b7ee20800b7fa387d3465bd77cf20c2d1068cd5c98e1ed57a","dweb:/ipfs/QmVSaVJf9FXFhdYEYeCEfjMVHrxDh5qL4CGkxdMWpQCrqG"],"license":"MIT"},"../../../../node_modules/@openzeppelin/contracts/utils/SlotDerivation.sol":{"keccak256":"0x8447b57b63810fe2e367c09496a966f143ec0e825d71ddb9fce2506cff84b618","urls":["bzz-raw://996cb48f793bf151555045b37138e36b3cdb31d6bc6552d3149285260be00cfb","dweb:/ipfs/QmcLaTTMNVbkMx58xhkp6GeFt4V3GtSyupZuaKG3vYW2Zc"],"license":"MIT"},"../../../../node_modules/@openzeppelin/contracts/utils/StorageSlot.sol":{"keccak256":"0xcf74f855663ce2ae00ed8352666b7935f6cddea2932fdf2c3ecd30a9b1cd0e97","urls":["bzz-raw://9f660b1f351b757dfe01438e59888f31f33ded3afcf5cb5b0d9bf9aa6f320a8b","dweb:/ipfs/QmarDJ5hZEgBtCmmrVzEZWjub9769eD686jmzb2XpSU1cM"],"license":"MIT"},"../../../../node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol":{"keccak256":"0xddce8e17e3d3f9ed818b4f4c4478a8262aab8b11ed322f1bf5ed705bb4bd97fa","urls":["bzz-raw://8084aa71a4cc7d2980972412a88fe4f114869faea3fefa5436431644eb5c0287","dweb:/ipfs/Qmbqfs5dRdPvHVKY8kTaeyc65NdqXRQwRK7h9s5UJEhD1p"],"license":"MIT"},"../../../../node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol":{"keccak256":"0x79796192ec90263f21b464d5bc90b777a525971d3de8232be80d9c4f9fb353b8","urls":["bzz-raw://f6fda447a62815e8064f47eff0dd1cf58d9207ad69b5d32280f8d7ed1d1e4621","dweb:/ipfs/QmfDRc7pxfaXB2Dh9np5Uf29Na3pQ7tafRS684wd3GLjVL"],"license":"MIT"},"../../../../node_modules/@openzeppelin/contracts/utils/math/Math.sol":{"keccak256":"0xa00be322d7db5786750ce0ac7e2f5b633ac30a5ed5fa1ced1e74acfc19acecea","urls":["bzz-raw://6c84e822f87cbdc4082533b626667b6928715bb2b1e8e7eb96954cebb9e38c8d","dweb:/ipfs/QmZmy9dgxLTerBAQDuuHqbL6EpgRxddqgv5KmwpXYVbKz1"],"license":"MIT"},"../../../../node_modules/@openzeppelin/contracts/utils/math/SafeCast.sol":{"keccak256":"0x195533c86d0ef72bcc06456a4f66a9b941f38eb403739b00f21fd7c1abd1ae54","urls":["bzz-raw://b1d578337048cad08c1c03041cca5978eff5428aa130c781b271ad9e5566e1f8","dweb:/ipfs/QmPFKL2r9CBsMwmUqqdcFPfHZB2qcs9g1HDrPxzWSxomvy"],"license":"MIT"}},"version":1},"id":2} as const;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Type } from "@sinclair/typebox";
|
|
2
|
+
|
|
3
|
+
export const erc1155Grammar = [
|
|
4
|
+
["type", Type.String()],
|
|
5
|
+
["to", Type.String()],
|
|
6
|
+
["from", Type.String()],
|
|
7
|
+
["tokenId", Type.String()],
|
|
8
|
+
["amount", Type.String()],
|
|
9
|
+
["isMint", Type.Boolean()],
|
|
10
|
+
["isBurn", Type.Boolean()],
|
|
11
|
+
["operator", Type.String()],
|
|
12
|
+
] as const;
|
|
13
|
+
|