@graphprotocol/graph-cli 0.37.3 → 0.37.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/package.json +5 -1
- package/babel.config.js +0 -3
- package/jest.config.js +0 -175
- package/src/bin.ts +0 -6
- package/src/cli.ts +0 -30
- package/src/codegen/schema.test.ts +0 -460
- package/src/codegen/schema.ts +0 -299
- package/src/codegen/template.ts +0 -45
- package/src/codegen/types/conversions.ts +0 -358
- package/src/codegen/types/index.test.ts +0 -715
- package/src/codegen/types/index.ts +0 -111
- package/src/codegen/typescript.ts +0 -224
- package/src/codegen/util.test.ts +0 -112
- package/src/codegen/util.ts +0 -54
- package/src/command-helpers/abi.ts +0 -99
- package/src/command-helpers/auth.ts +0 -46
- package/src/command-helpers/compiler.ts +0 -60
- package/src/command-helpers/data-sources.ts +0 -36
- package/src/command-helpers/fs.ts +0 -5
- package/src/command-helpers/gluegun.ts +0 -52
- package/src/command-helpers/ipfs-http-client.d.ts +0 -1
- package/src/command-helpers/ipfs.ts +0 -3
- package/src/command-helpers/jsonrpc.ts +0 -22
- package/src/command-helpers/network.test.ts +0 -85
- package/src/command-helpers/network.ts +0 -133
- package/src/command-helpers/node.ts +0 -46
- package/src/command-helpers/scaffold.ts +0 -174
- package/src/command-helpers/spinner.ts +0 -60
- package/src/command-helpers/studio.test.ts +0 -84
- package/src/command-helpers/studio.ts +0 -25
- package/src/command-helpers/subgraph.ts +0 -21
- package/src/command-helpers/version.test.ts +0 -241
- package/src/command-helpers/version.ts +0 -53
- package/src/commands/add.ts +0 -220
- package/src/commands/auth.ts +0 -138
- package/src/commands/binary-install-raw.d.ts +0 -1
- package/src/commands/build.ts +0 -147
- package/src/commands/codegen.ts +0 -123
- package/src/commands/create.ts +0 -109
- package/src/commands/deploy.ts +0 -388
- package/src/commands/init.ts +0 -1060
- package/src/commands/local.ts +0 -539
- package/src/commands/remove.ts +0 -110
- package/src/commands/test.ts +0 -369
- package/src/compiler/asc.ts +0 -77
- package/src/compiler/index.ts +0 -677
- package/src/debug.ts +0 -15
- package/src/migrations/mapping_api_version_0_0_1.ts +0 -75
- package/src/migrations/mapping_api_version_0_0_2.ts +0 -75
- package/src/migrations/mapping_api_version_0_0_3.ts +0 -75
- package/src/migrations/mapping_api_version_0_0_4.ts +0 -77
- package/src/migrations/mapping_api_version_0_0_5.ts +0 -77
- package/src/migrations/spec_version_0_0_2.ts +0 -24
- package/src/migrations/spec_version_0_0_3.ts +0 -29
- package/src/migrations/util/load-manifest.ts +0 -10
- package/src/migrations/util/versions.ts +0 -27
- package/src/migrations.ts +0 -33
- package/src/protocols/arweave/manifest.graphql +0 -57
- package/src/protocols/arweave/scaffold/manifest.ts +0 -14
- package/src/protocols/arweave/scaffold/mapping.ts +0 -49
- package/src/protocols/arweave/subgraph.ts +0 -22
- package/src/protocols/contract.ts +0 -9
- package/src/protocols/cosmos/manifest.graphql +0 -76
- package/src/protocols/cosmos/scaffold/manifest.ts +0 -11
- package/src/protocols/cosmos/scaffold/mapping.ts +0 -35
- package/src/protocols/cosmos/subgraph.ts +0 -27
- package/src/protocols/ethereum/abi.ts +0 -153
- package/src/protocols/ethereum/codegen/abi.test.ts +0 -330
- package/src/protocols/ethereum/codegen/abi.ts +0 -719
- package/src/protocols/ethereum/codegen/template.ts +0 -41
- package/src/protocols/ethereum/contract.ts +0 -24
- package/src/protocols/ethereum/manifest.graphql +0 -94
- package/src/protocols/ethereum/scaffold/manifest.ts +0 -28
- package/src/protocols/ethereum/scaffold/mapping.ts +0 -76
- package/src/protocols/ethereum/subgraph.ts +0 -189
- package/src/protocols/ethereum/type-generator.ts +0 -191
- package/src/protocols/index.ts +0 -287
- package/src/protocols/ipfs/codegen/file_template.ts +0 -43
- package/src/protocols/near/contract.ts +0 -47
- package/src/protocols/near/manifest.graphql +0 -64
- package/src/protocols/near/scaffold/manifest.ts +0 -13
- package/src/protocols/near/scaffold/mapping.ts +0 -35
- package/src/protocols/near/subgraph.ts +0 -22
- package/src/protocols/subgraph.ts +0 -12
- package/src/protocols/substreams/manifest.graphql +0 -45
- package/src/protocols/substreams/scaffold/manifest.ts +0 -8
- package/src/protocols/substreams/subgraph.ts +0 -22
- package/src/scaffold/cosmos.test.ts +0 -83
- package/src/scaffold/ethereum.test.ts +0 -512
- package/src/scaffold/index.ts +0 -172
- package/src/scaffold/mapping.ts +0 -44
- package/src/scaffold/near.test.ts +0 -86
- package/src/scaffold/schema.ts +0 -89
- package/src/scaffold/tests.ts +0 -217
- package/src/schema.ts +0 -26
- package/src/subgraph.ts +0 -302
- package/src/type-generator.ts +0 -266
- package/src/validation/contract.ts +0 -51
- package/src/validation/index.ts +0 -5
- package/src/validation/manifest.ts +0 -360
- package/src/validation/schema.test.ts +0 -38
- package/src/validation/schema.ts +0 -957
- package/src/watcher.ts +0 -96
- package/tests/cli/globalSetup.ts +0 -8
- package/tests/cli/globalTeardown.ts +0 -8
- package/tests/cli/init/ethereum/abis/Marketplace.json +0 -408
- package/tests/cli/init/ethereum/abis/OverloadedElements.json +0 -91
- package/tests/cli/init/ethereum/abis/SoloMargin.json +0 -2729
- package/tests/cli/init/ethereum/from-contract-with-abi-and-structs.stderr +0 -14
- package/tests/cli/init/ethereum/from-contract-with-abi-and-structs.stdout +0 -12
- package/tests/cli/init/ethereum/from-contract-with-abi.stderr +0 -14
- package/tests/cli/init/ethereum/from-contract-with-abi.stdout +0 -12
- package/tests/cli/init/ethereum/from-contract-with-overloaded-elements.stderr +0 -14
- package/tests/cli/init/ethereum/from-contract-with-overloaded-elements.stdout +0 -12
- package/tests/cli/init/ethereum/from-contract.stderr +0 -16
- package/tests/cli/init/ethereum/from-contract.stdout +0 -12
- package/tests/cli/init/ethereum/from-example.stderr +0 -12
- package/tests/cli/init/ethereum/from-example.stdout +0 -12
- package/tests/cli/init/near/from-contract.stderr +0 -14
- package/tests/cli/init/near/from-contract.stdout +0 -12
- package/tests/cli/init.test.ts +0 -157
- package/tests/cli/spawn-command.d.ts +0 -7
- package/tests/cli/util.ts +0 -132
- package/tests/cli/validation/abi-not-found/Abi.json +0 -7
- package/tests/cli/validation/abi-not-found/mapping.ts +0 -0
- package/tests/cli/validation/abi-not-found/schema.graphql +0 -3
- package/tests/cli/validation/abi-not-found/subgraph.yaml +0 -42
- package/tests/cli/validation/abi-not-found copy.stderr +0 -13
- package/tests/cli/validation/big-decimal-is-valid/Abi.json +0 -7
- package/tests/cli/validation/big-decimal-is-valid/mapping.ts +0 -0
- package/tests/cli/validation/big-decimal-is-valid/schema.graphql +0 -4
- package/tests/cli/validation/big-decimal-is-valid/subgraph.yaml +0 -23
- package/tests/cli/validation/call-function-not-found/Abi.json +0 -57
- package/tests/cli/validation/call-function-not-found/mapping.ts +0 -0
- package/tests/cli/validation/call-function-not-found/schema.graphql +0 -3
- package/tests/cli/validation/call-function-not-found/subgraph.yaml +0 -22
- package/tests/cli/validation/call-function-not-found.stderr +0 -10
- package/tests/cli/validation/call-handler-with-tuple/Abi.json +0 -24
- package/tests/cli/validation/call-handler-with-tuple/generated/schema.ts +0 -44
- package/tests/cli/validation/call-handler-with-tuple/mapping.ts +0 -0
- package/tests/cli/validation/call-handler-with-tuple/schema.graphql +0 -3
- package/tests/cli/validation/call-handler-with-tuple/subgraph.yaml +0 -22
- package/tests/cli/validation/call-handler-with-tuple.stderr +0 -24
- package/tests/cli/validation/conflicting-network-names/Abi.json +0 -7
- package/tests/cli/validation/conflicting-network-names/mapping.ts +0 -0
- package/tests/cli/validation/conflicting-network-names/schema.graphql +0 -3
- package/tests/cli/validation/conflicting-network-names/subgraph.yaml +0 -41
- package/tests/cli/validation/conflicting-network-names.stderr +0 -10
- package/tests/cli/validation/conflicting-protocol-names/Abi.json +0 -7
- package/tests/cli/validation/conflicting-protocol-names/mapping.ts +0 -0
- package/tests/cli/validation/conflicting-protocol-names/schema.graphql +0 -3
- package/tests/cli/validation/conflicting-protocol-names/subgraph.yaml +0 -41
- package/tests/cli/validation/conflicting-protocol-names.stderr +0 -10
- package/tests/cli/validation/derived-from-target-type-missing/Abi.json +0 -6
- package/tests/cli/validation/derived-from-target-type-missing/mapping.ts +0 -0
- package/tests/cli/validation/derived-from-target-type-missing/schema.graphql +0 -4
- package/tests/cli/validation/derived-from-target-type-missing/subgraph.yaml +0 -22
- package/tests/cli/validation/derived-from-target-type-missing.stderr +0 -5
- package/tests/cli/validation/derived-from-with-interface/Gravity.json +0 -1
- package/tests/cli/validation/derived-from-with-interface/mapping.ts +0 -22
- package/tests/cli/validation/derived-from-with-interface/schema.graphql +0 -19
- package/tests/cli/validation/derived-from-with-interface/subgraph.yaml +0 -25
- package/tests/cli/validation/duplicate-data-source-name/Abi.json +0 -7
- package/tests/cli/validation/duplicate-data-source-name/mapping.ts +0 -0
- package/tests/cli/validation/duplicate-data-source-name/schema.graphql +0 -4
- package/tests/cli/validation/duplicate-data-source-name/subgraph.yaml +0 -40
- package/tests/cli/validation/duplicate-data-source-name.stderr +0 -5
- package/tests/cli/validation/duplicate-template-name/Abi.json +0 -7
- package/tests/cli/validation/duplicate-template-name/mapping.ts +0 -0
- package/tests/cli/validation/duplicate-template-name/schema.graphql +0 -4
- package/tests/cli/validation/duplicate-template-name/subgraph.yaml +0 -59
- package/tests/cli/validation/duplicate-template-name.stderr +0 -5
- package/tests/cli/validation/entity-field-args/Abi.json +0 -7
- package/tests/cli/validation/entity-field-args/mapping.ts +0 -0
- package/tests/cli/validation/entity-field-args/schema.graphql +0 -4
- package/tests/cli/validation/entity-field-args/subgraph.yaml +0 -22
- package/tests/cli/validation/entity-field-args.stderr +0 -5
- package/tests/cli/validation/ethereum-contract-without-handlers/Abi.json +0 -7
- package/tests/cli/validation/ethereum-contract-without-handlers/mapping.ts +0 -0
- package/tests/cli/validation/ethereum-contract-without-handlers/schema.graphql +0 -3
- package/tests/cli/validation/ethereum-contract-without-handlers/subgraph.yaml +0 -19
- package/tests/cli/validation/ethereum-contract-without-handlers.stderr +0 -6
- package/tests/cli/validation/event-not-found/Abi.json +0 -7
- package/tests/cli/validation/event-not-found/mapping.ts +0 -0
- package/tests/cli/validation/event-not-found/schema.graphql +0 -3
- package/tests/cli/validation/event-not-found/subgraph.yaml +0 -40
- package/tests/cli/validation/event-not-found.stderr +0 -12
- package/tests/cli/validation/example-values-found/Abi.json +0 -7
- package/tests/cli/validation/example-values-found/generated/ExampleSubgraph/ExampleContract.ts +0 -35
- package/tests/cli/validation/example-values-found/generated/schema.ts +0 -44
- package/tests/cli/validation/example-values-found/mapping.ts +0 -0
- package/tests/cli/validation/example-values-found/schema.graphql +0 -3
- package/tests/cli/validation/example-values-found/subgraph.yaml +0 -24
- package/tests/cli/validation/example-values-found.stderr +0 -34
- package/tests/cli/validation/invalid-abis/InvalidAbi.json +0 -1
- package/tests/cli/validation/invalid-abis/mapping.ts +0 -0
- package/tests/cli/validation/invalid-abis/schema.graphql +0 -3
- package/tests/cli/validation/invalid-abis/subgraph.yaml +0 -22
- package/tests/cli/validation/invalid-abis.stderr +0 -5
- package/tests/cli/validation/invalid-contract-addresses/Abi.json +0 -7
- package/tests/cli/validation/invalid-contract-addresses/mapping.ts +0 -0
- package/tests/cli/validation/invalid-contract-addresses/schema.graphql +0 -3
- package/tests/cli/validation/invalid-contract-addresses/subgraph.yaml +0 -58
- package/tests/cli/validation/invalid-contract-addresses.stderr +0 -14
- package/tests/cli/validation/invalid-data-source-template/mapping.ts +0 -0
- package/tests/cli/validation/invalid-data-source-template/schema.graphql +0 -3
- package/tests/cli/validation/invalid-data-source-template/subgraph.yaml +0 -32
- package/tests/cli/validation/invalid-data-source-template.stderr +0 -30
- package/tests/cli/validation/invalid-entity-field-types/Abi.json +0 -7
- package/tests/cli/validation/invalid-entity-field-types/mapping.ts +0 -0
- package/tests/cli/validation/invalid-entity-field-types/schema.graphql +0 -157
- package/tests/cli/validation/invalid-entity-field-types/subgraph.yaml +0 -22
- package/tests/cli/validation/invalid-entity-field-types.stderr +0 -148
- package/tests/cli/validation/invalid-fulltext-directive/Abi.json +0 -7
- package/tests/cli/validation/invalid-fulltext-directive/mapping.ts +0 -0
- package/tests/cli/validation/invalid-fulltext-directive/schema.graphql +0 -140
- package/tests/cli/validation/invalid-fulltext-directive/subgraph.yaml +0 -22
- package/tests/cli/validation/invalid-fulltext-directive.stderr +0 -32
- package/tests/cli/validation/invalid-graphql-schema/Abi.json +0 -7
- package/tests/cli/validation/invalid-graphql-schema/mapping.ts +0 -0
- package/tests/cli/validation/invalid-graphql-schema/schema.graphql +0 -8
- package/tests/cli/validation/invalid-graphql-schema/subgraph.yaml +0 -22
- package/tests/cli/validation/invalid-graphql-schema.stderr +0 -25
- package/tests/cli/validation/invalid-manifest/subgraph.yaml +0 -13
- package/tests/cli/validation/invalid-manifest-cannot-infer-protocol/subgraph.yaml +0 -12
- package/tests/cli/validation/invalid-manifest-cannot-infer-protocol.stderr +0 -5
- package/tests/cli/validation/invalid-manifest.stderr +0 -28
- package/tests/cli/validation/missing-entity-id/Abi.json +0 -7
- package/tests/cli/validation/missing-entity-id/mapping.ts +0 -0
- package/tests/cli/validation/missing-entity-id/schema.graphql +0 -3
- package/tests/cli/validation/missing-entity-id/subgraph.yaml +0 -22
- package/tests/cli/validation/missing-entity-id/types/ExampleSubgraph/ExampleContract.ts +0 -35
- package/tests/cli/validation/missing-entity-id/types/schema.ts +0 -27
- package/tests/cli/validation/missing-entity-id.stderr +0 -5
- package/tests/cli/validation/missing-or-invalid-derived-from-fields/Abi.json +0 -7
- package/tests/cli/validation/missing-or-invalid-derived-from-fields/mapping.ts +0 -0
- package/tests/cli/validation/missing-or-invalid-derived-from-fields/schema.graphql +0 -40
- package/tests/cli/validation/missing-or-invalid-derived-from-fields/subgraph.yaml +0 -22
- package/tests/cli/validation/missing-or-invalid-derived-from-fields.stderr +0 -10
- package/tests/cli/validation/missing-or-invalid-derived-from-fields.stdout +0 -0
- package/tests/cli/validation/near-is-valid/mapping.ts +0 -0
- package/tests/cli/validation/near-is-valid/schema.graphql +0 -8
- package/tests/cli/validation/near-is-valid/subgraph.yaml +0 -30
- package/tests/cli/validation/nested-template-nice-error/Abi.json +0 -7
- package/tests/cli/validation/nested-template-nice-error/mapping.ts +0 -0
- package/tests/cli/validation/nested-template-nice-error/schema.graphql +0 -3
- package/tests/cli/validation/nested-template-nice-error/subgraph.yaml +0 -35
- package/tests/cli/validation/nested-template-nice-error.stderr +0 -5
- package/tests/cli/validation/no-network-names/Abi.json +0 -7
- package/tests/cli/validation/no-network-names/mapping.ts +0 -0
- package/tests/cli/validation/no-network-names/schema.graphql +0 -3
- package/tests/cli/validation/no-network-names/subgraph.yaml +0 -40
- package/tests/cli/validation/no-network-names.stderr +0 -34
- package/tests/cli/validation/source-without-address-is-valid/Abi.json +0 -7
- package/tests/cli/validation/source-without-address-is-valid/generated/ExampleSubgraph/ExampleContract.ts +0 -35
- package/tests/cli/validation/source-without-address-is-valid/mapping.ts +0 -0
- package/tests/cli/validation/source-without-address-is-valid/schema.graphql +0 -3
- package/tests/cli/validation/source-without-address-is-valid/subgraph.yaml +0 -23
- package/tests/cli/validation/source-without-address-is-valid.stderr +0 -24
- package/tests/cli/validation/topic0-is-valid/Abi.json +0 -7
- package/tests/cli/validation/topic0-is-valid/mapping.ts +0 -0
- package/tests/cli/validation/topic0-is-valid/schema.graphql +0 -4
- package/tests/cli/validation/topic0-is-valid/subgraph.yaml +0 -24
- package/tests/cli/validation.test.ts +0 -226
- package/tsconfig.build.json +0 -4
- package/tsconfig.json +0 -19
|
@@ -1,715 +0,0 @@
|
|
|
1
|
-
import * as codegen from '.';
|
|
2
|
-
|
|
3
|
-
describe('ethereum.Value -> AssemblyScript', () => {
|
|
4
|
-
// Scalar values
|
|
5
|
-
|
|
6
|
-
test('address -> Address', () => {
|
|
7
|
-
expect(codegen.ethereumToAsc('x', 'address')).toBe('x.toAddress()');
|
|
8
|
-
expect(codegen.ascTypeForEthereum('address')).toBe('Address');
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
test('bool -> boolean', () => {
|
|
12
|
-
expect(codegen.ethereumToAsc('x', 'bool')).toBe('x.toBoolean()');
|
|
13
|
-
expect(codegen.ascTypeForEthereum('bool')).toBe('boolean');
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
test('byte -> Bytes', () => {
|
|
17
|
-
expect(codegen.ethereumToAsc('x', 'byte')).toBe('x.toBytes()');
|
|
18
|
-
expect(codegen.ascTypeForEthereum('byte')).toBe('Bytes');
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
test('bytes -> Bytes', () => {
|
|
22
|
-
expect(codegen.ethereumToAsc('x', 'bytes')).toBe('x.toBytes()');
|
|
23
|
-
expect(codegen.ascTypeForEthereum('bytes')).toBe('Bytes');
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
test('bytes0 (invalid)', () => {
|
|
27
|
-
expect(() => codegen.ethereumToAsc('x', 'bytes0')).toThrow();
|
|
28
|
-
expect(() => codegen.ascTypeForEthereum('bytes0')).toThrow();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
test('bytes1..32 -> Bytes', () => {
|
|
32
|
-
for (let i = 1; i <= 32; i++) {
|
|
33
|
-
expect(codegen.ethereumToAsc('x', `bytes${i}`)).toBe('x.toBytes()');
|
|
34
|
-
expect(codegen.ascTypeForEthereum(`bytes${i}`)).toBe('Bytes');
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test('bytes33 (invalid)', () => {
|
|
39
|
-
expect(() => codegen.ethereumToAsc('x', 'bytes33')).toThrow();
|
|
40
|
-
expect(() => codegen.ascTypeForEthereum('bytes33')).toThrow();
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test('int8..32, uint8..uint24 -> i32', () => {
|
|
44
|
-
for (let i = 8; i <= 32; i += 8) {
|
|
45
|
-
expect(codegen.ethereumToAsc('x', `int${i}`)).toBe('x.toI32()');
|
|
46
|
-
expect(codegen.ascTypeForEthereum(`int${i}`)).toBe('i32');
|
|
47
|
-
}
|
|
48
|
-
for (let i = 8; i <= 24; i += 8) {
|
|
49
|
-
expect(codegen.ethereumToAsc('x', `uint${i}`)).toBe('x.toI32()');
|
|
50
|
-
expect(codegen.ascTypeForEthereum(`uint${i}`)).toBe('i32');
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
test('uint32 -> BigInt', () => {
|
|
55
|
-
expect(codegen.ethereumToAsc('x', `uint32`)).toBe('x.toBigInt()');
|
|
56
|
-
expect(codegen.ascTypeForEthereum('uint32')).toBe('BigInt');
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
test('(u)int40..256 -> BigInt', () => {
|
|
60
|
-
for (let i = 40; i <= 256; i += 8) {
|
|
61
|
-
expect(codegen.ethereumToAsc('x', `int${i}`)).toBe('x.toBigInt()');
|
|
62
|
-
expect(codegen.ethereumToAsc('x', `uint${i}`)).toBe('x.toBigInt()');
|
|
63
|
-
expect(codegen.ascTypeForEthereum(`int${i}`)).toBe('BigInt');
|
|
64
|
-
expect(codegen.ascTypeForEthereum(`uint${i}`)).toBe('BigInt');
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
test('string -> String', () => {
|
|
69
|
-
expect(codegen.ethereumToAsc('x', 'string')).toBe('x.toString()');
|
|
70
|
-
expect(codegen.ascTypeForEthereum('string')).toBe('string');
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
// Array values
|
|
74
|
-
|
|
75
|
-
test('address[*] -> Array<Address>', () => {
|
|
76
|
-
expect(codegen.ethereumToAsc('x', 'address[]')).toBe('x.toAddressArray()');
|
|
77
|
-
expect(codegen.ethereumToAsc('x', 'address[1]')).toBe('x.toAddressArray()');
|
|
78
|
-
expect(codegen.ethereumToAsc('x', 'address[123]')).toBe('x.toAddressArray()');
|
|
79
|
-
expect(codegen.ascTypeForEthereum('address[]')).toBe('Array<Address>');
|
|
80
|
-
expect(codegen.ascTypeForEthereum('address[1]')).toBe('Array<Address>');
|
|
81
|
-
expect(codegen.ascTypeForEthereum('address[123]')).toBe('Array<Address>');
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
test('bool[*] -> Array<boolean>', () => {
|
|
85
|
-
expect(codegen.ethereumToAsc('x', 'bool[]')).toBe('x.toBooleanArray()');
|
|
86
|
-
expect(codegen.ethereumToAsc('x', 'bool[5]')).toBe('x.toBooleanArray()');
|
|
87
|
-
expect(codegen.ethereumToAsc('x', 'bool[275]')).toBe('x.toBooleanArray()');
|
|
88
|
-
expect(codegen.ascTypeForEthereum('bool[]')).toBe('Array<boolean>');
|
|
89
|
-
expect(codegen.ascTypeForEthereum('bool[5]')).toBe('Array<boolean>');
|
|
90
|
-
expect(codegen.ascTypeForEthereum('bool[275]')).toBe('Array<boolean>');
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
test('byte[*] -> Array<Bytes>', () => {
|
|
94
|
-
expect(codegen.ethereumToAsc('x', 'byte[]')).toBe('x.toBytesArray()');
|
|
95
|
-
expect(codegen.ethereumToAsc('x', 'byte[7]')).toBe('x.toBytesArray()');
|
|
96
|
-
expect(codegen.ethereumToAsc('x', 'byte[553]')).toBe('x.toBytesArray()');
|
|
97
|
-
expect(codegen.ascTypeForEthereum('byte[]')).toBe('Array<Bytes>');
|
|
98
|
-
expect(codegen.ascTypeForEthereum('byte[7]')).toBe('Array<Bytes>');
|
|
99
|
-
expect(codegen.ascTypeForEthereum('byte[553]')).toBe('Array<Bytes>');
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
test('bytes[*] -> Array<Bytes>', () => {
|
|
103
|
-
expect(codegen.ethereumToAsc('x', 'bytes[]')).toBe('x.toBytesArray()');
|
|
104
|
-
expect(codegen.ethereumToAsc('x', 'bytes[14]')).toBe('x.toBytesArray()');
|
|
105
|
-
expect(codegen.ethereumToAsc('x', 'bytes[444]')).toBe('x.toBytesArray()');
|
|
106
|
-
expect(codegen.ascTypeForEthereum('bytes[]')).toBe('Array<Bytes>');
|
|
107
|
-
expect(codegen.ascTypeForEthereum('bytes[14]')).toBe('Array<Bytes>');
|
|
108
|
-
expect(codegen.ascTypeForEthereum('bytes[444]')).toBe('Array<Bytes>');
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
test('bytes0[*] (invalid)', () => {
|
|
112
|
-
expect(() => codegen.ethereumToAsc('x', 'bytes0[]')).toThrow();
|
|
113
|
-
expect(() => codegen.ethereumToAsc('x', 'bytes0[83]')).toThrow();
|
|
114
|
-
expect(() => codegen.ethereumToAsc('x', 'bytes0[123]')).toThrow();
|
|
115
|
-
expect(() => codegen.ascTypeForEthereum('bytes0[]')).toThrow();
|
|
116
|
-
expect(() => codegen.ascTypeForEthereum('bytes0[83]')).toThrow();
|
|
117
|
-
expect(() => codegen.ascTypeForEthereum('bytes0[123]')).toThrow();
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
test('bytes1..32[*] -> Array<Bytes>', () => {
|
|
121
|
-
for (let i = 1; i <= 32; i++) {
|
|
122
|
-
expect(codegen.ethereumToAsc('x', `bytes${i}[]`)).toBe('x.toBytesArray()');
|
|
123
|
-
expect(codegen.ethereumToAsc('x', `bytes${i}[7]`)).toBe('x.toBytesArray()');
|
|
124
|
-
expect(codegen.ethereumToAsc('x', `bytes${i}[432]`)).toBe('x.toBytesArray()');
|
|
125
|
-
expect(codegen.ascTypeForEthereum(`bytes${i}[]`)).toBe('Array<Bytes>');
|
|
126
|
-
expect(codegen.ascTypeForEthereum(`bytes${i}[7]`)).toBe('Array<Bytes>');
|
|
127
|
-
expect(codegen.ascTypeForEthereum(`bytes${i}[432]`)).toBe('Array<Bytes>');
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
test('bytes33[*] (invalid)', () => {
|
|
132
|
-
expect(() => codegen.ethereumToAsc('x', 'bytes33[]')).toThrow();
|
|
133
|
-
expect(() => codegen.ethereumToAsc('x', 'bytes33[58]')).toThrow();
|
|
134
|
-
expect(() => codegen.ethereumToAsc('x', 'bytes33[394]')).toThrow();
|
|
135
|
-
expect(() => codegen.ascTypeForEthereum('bytes33[]')).toThrow();
|
|
136
|
-
expect(() => codegen.ascTypeForEthereum('bytes33[58]')).toThrow();
|
|
137
|
-
expect(() => codegen.ascTypeForEthereum('bytes33[394]')).toThrow();
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
test('int8..32[*], uint8..24[*] -> Array<i32>', () => {
|
|
141
|
-
for (let i = 8; i <= 32; i += 8) {
|
|
142
|
-
expect(codegen.ethereumToAsc('x', `int${i}[]`)).toBe('x.toI32Array()');
|
|
143
|
-
expect(codegen.ethereumToAsc('x', `int${i}[6]`)).toBe('x.toI32Array()');
|
|
144
|
-
expect(codegen.ethereumToAsc('x', `int${i}[4638]`)).toBe('x.toI32Array()');
|
|
145
|
-
expect(codegen.ascTypeForEthereum(`int${i}[]`)).toBe('Array<i32>');
|
|
146
|
-
expect(codegen.ascTypeForEthereum(`int${i}[6]`)).toBe('Array<i32>');
|
|
147
|
-
expect(codegen.ascTypeForEthereum(`int${i}[4638]`)).toBe('Array<i32>');
|
|
148
|
-
}
|
|
149
|
-
for (let i = 8; i <= 24; i += 8) {
|
|
150
|
-
expect(codegen.ethereumToAsc('x', `uint${i}[]`)).toBe('x.toI32Array()');
|
|
151
|
-
expect(codegen.ethereumToAsc('x', `uint${i}[6]`)).toBe('x.toI32Array()');
|
|
152
|
-
expect(codegen.ethereumToAsc('x', `uint${i}[593]`)).toBe('x.toI32Array()');
|
|
153
|
-
expect(codegen.ascTypeForEthereum(`uint${i}[]`)).toBe('Array<i32>');
|
|
154
|
-
expect(codegen.ascTypeForEthereum(`uint${i}[6]`)).toBe('Array<i32>');
|
|
155
|
-
expect(codegen.ascTypeForEthereum(`uint${i}[593]`)).toBe('Array<i32>');
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
test('uint32[*] -> Array<BigInt>', () => {
|
|
160
|
-
expect(codegen.ethereumToAsc('x', `uint32[]`)).toBe('x.toBigIntArray()');
|
|
161
|
-
expect(codegen.ethereumToAsc('x', `uint32[6]`)).toBe('x.toBigIntArray()');
|
|
162
|
-
expect(codegen.ethereumToAsc('x', `uint32[593]`)).toBe('x.toBigIntArray()');
|
|
163
|
-
expect(codegen.ascTypeForEthereum(`uint32[]`)).toBe('Array<BigInt>');
|
|
164
|
-
expect(codegen.ascTypeForEthereum(`uint32[6]`)).toBe('Array<BigInt>');
|
|
165
|
-
expect(codegen.ascTypeForEthereum(`uint32[593]`)).toBe('Array<BigInt>');
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
test('(u)int40..256[*] -> Array<BigInt>', () => {
|
|
169
|
-
for (let i = 40; i <= 256; i += 8) {
|
|
170
|
-
expect(codegen.ethereumToAsc('x', `int${i}[]`)).toBe('x.toBigIntArray()');
|
|
171
|
-
expect(codegen.ethereumToAsc('x', `int${i}[7]`)).toBe('x.toBigIntArray()');
|
|
172
|
-
expect(codegen.ethereumToAsc('x', `int${i}[6833]`)).toBe('x.toBigIntArray()');
|
|
173
|
-
expect(codegen.ascTypeForEthereum(`int${i}[]`)).toBe('Array<BigInt>');
|
|
174
|
-
expect(codegen.ascTypeForEthereum(`int${i}[7]`)).toBe('Array<BigInt>');
|
|
175
|
-
expect(codegen.ascTypeForEthereum(`int${i}[6833]`)).toBe('Array<BigInt>');
|
|
176
|
-
|
|
177
|
-
expect(codegen.ethereumToAsc('x', `uint${i}[]`)).toBe('x.toBigIntArray()');
|
|
178
|
-
expect(codegen.ethereumToAsc('x', `uint${i}[23]`)).toBe('x.toBigIntArray()');
|
|
179
|
-
expect(codegen.ethereumToAsc('x', `uint${i}[467]`)).toBe('x.toBigIntArray()');
|
|
180
|
-
expect(codegen.ascTypeForEthereum(`uint${i}[]`)).toBe('Array<BigInt>');
|
|
181
|
-
expect(codegen.ascTypeForEthereum(`uint${i}[23]`)).toBe('Array<BigInt>');
|
|
182
|
-
expect(codegen.ascTypeForEthereum(`uint${i}[467]`)).toBe('Array<BigInt>');
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
test('string[*] -> Array<string>', () => {
|
|
187
|
-
expect(codegen.ethereumToAsc('x', 'string[]')).toBe('x.toStringArray()');
|
|
188
|
-
expect(codegen.ethereumToAsc('x', 'string[4]')).toBe('x.toStringArray()');
|
|
189
|
-
expect(codegen.ethereumToAsc('x', 'string[754]')).toBe('x.toStringArray()');
|
|
190
|
-
expect(codegen.ascTypeForEthereum('string[]')).toBe('Array<string>');
|
|
191
|
-
expect(codegen.ascTypeForEthereum('string[4]')).toBe('Array<string>');
|
|
192
|
-
expect(codegen.ascTypeForEthereum('string[754]')).toBe('Array<string>');
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
// Multi dimensional arrays
|
|
196
|
-
|
|
197
|
-
test('address[*][*] -> Array<Array<Address>>', () => {
|
|
198
|
-
expect(codegen.ethereumToAsc('x', 'address[][]')).toBe('x.toAddressMatrix()');
|
|
199
|
-
expect(codegen.ethereumToAsc('x', 'address[5][]')).toBe('x.toAddressMatrix()');
|
|
200
|
-
expect(codegen.ethereumToAsc('x', 'address[][4]')).toBe('x.toAddressMatrix()');
|
|
201
|
-
expect(codegen.ethereumToAsc('x', 'address[1][2]')).toBe('x.toAddressMatrix()');
|
|
202
|
-
expect(codegen.ethereumToAsc('x', 'address[123][321]')).toBe('x.toAddressMatrix()');
|
|
203
|
-
|
|
204
|
-
expect(codegen.ascTypeForEthereum('address[][]')).toBe('Array<Array<Address>>');
|
|
205
|
-
expect(codegen.ascTypeForEthereum('address[5][]')).toBe('Array<Array<Address>>');
|
|
206
|
-
expect(codegen.ascTypeForEthereum('address[][4]')).toBe('Array<Array<Address>>');
|
|
207
|
-
expect(codegen.ascTypeForEthereum('address[1][2]')).toBe('Array<Array<Address>>');
|
|
208
|
-
expect(codegen.ascTypeForEthereum('address[123][321]')).toBe('Array<Array<Address>>');
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
test('bool[*][*] -> Array<Array<boolean>>', () => {
|
|
212
|
-
expect(codegen.ethereumToAsc('x', 'bool[][]')).toBe('x.toBooleanMatrix()');
|
|
213
|
-
expect(codegen.ethereumToAsc('x', 'bool[1][]')).toBe('x.toBooleanMatrix()');
|
|
214
|
-
expect(codegen.ethereumToAsc('x', 'bool[][3]')).toBe('x.toBooleanMatrix()');
|
|
215
|
-
expect(codegen.ethereumToAsc('x', 'bool[5][2]')).toBe('x.toBooleanMatrix()');
|
|
216
|
-
expect(codegen.ethereumToAsc('x', 'bool[275][572]')).toBe('x.toBooleanMatrix()');
|
|
217
|
-
|
|
218
|
-
expect(codegen.ascTypeForEthereum('bool[][]')).toBe('Array<Array<boolean>>');
|
|
219
|
-
expect(codegen.ascTypeForEthereum('bool[1][]')).toBe('Array<Array<boolean>>');
|
|
220
|
-
expect(codegen.ascTypeForEthereum('bool[][3]')).toBe('Array<Array<boolean>>');
|
|
221
|
-
expect(codegen.ascTypeForEthereum('bool[5][2]')).toBe('Array<Array<boolean>>');
|
|
222
|
-
expect(codegen.ascTypeForEthereum('bool[275][572]')).toBe('Array<Array<boolean>>');
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
test('byte[*][*] -> Array<Array<Bytes>>', () => {
|
|
226
|
-
expect(codegen.ethereumToAsc('x', 'byte[][]')).toBe('x.toBytesMatrix()');
|
|
227
|
-
expect(codegen.ethereumToAsc('x', 'byte[7][]')).toBe('x.toBytesMatrix()');
|
|
228
|
-
expect(codegen.ethereumToAsc('x', 'byte[][8]')).toBe('x.toBytesMatrix()');
|
|
229
|
-
expect(codegen.ethereumToAsc('x', 'byte[553][355]')).toBe('x.toBytesMatrix()');
|
|
230
|
-
|
|
231
|
-
expect(codegen.ascTypeForEthereum('byte[][]')).toBe('Array<Array<Bytes>>');
|
|
232
|
-
expect(codegen.ascTypeForEthereum('byte[7][]')).toBe('Array<Array<Bytes>>');
|
|
233
|
-
expect(codegen.ascTypeForEthereum('byte[][8]')).toBe('Array<Array<Bytes>>');
|
|
234
|
-
expect(codegen.ascTypeForEthereum('byte[553][355]')).toBe('Array<Array<Bytes>>');
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
test('bytes[*][*] -> Array<Array<Bytes>>', () => {
|
|
238
|
-
expect(codegen.ethereumToAsc('x', 'bytes[][]')).toBe('x.toBytesMatrix()');
|
|
239
|
-
expect(codegen.ethereumToAsc('x', 'bytes[14][]')).toBe('x.toBytesMatrix()');
|
|
240
|
-
expect(codegen.ethereumToAsc('x', 'bytes[][41]')).toBe('x.toBytesMatrix()');
|
|
241
|
-
expect(codegen.ethereumToAsc('x', 'bytes[444][555]')).toBe('x.toBytesMatrix()');
|
|
242
|
-
|
|
243
|
-
expect(codegen.ascTypeForEthereum('bytes[][]')).toBe('Array<Array<Bytes>>');
|
|
244
|
-
expect(codegen.ascTypeForEthereum('bytes[14][]')).toBe('Array<Array<Bytes>>');
|
|
245
|
-
expect(codegen.ascTypeForEthereum('bytes[][41]')).toBe('Array<Array<Bytes>>');
|
|
246
|
-
expect(codegen.ascTypeForEthereum('bytes[444][555]')).toBe('Array<Array<Bytes>>');
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
test('bytes0[*][*] (invalid)', () => {
|
|
250
|
-
expect(() => codegen.ethereumToAsc('x', 'bytes0[][]')).toThrow();
|
|
251
|
-
expect(() => codegen.ethereumToAsc('x', 'bytes0[83][]')).toThrow();
|
|
252
|
-
expect(() => codegen.ethereumToAsc('x', 'bytes0[][83]')).toThrow();
|
|
253
|
-
expect(() => codegen.ethereumToAsc('x', 'bytes0[123][321]')).toThrow();
|
|
254
|
-
|
|
255
|
-
expect(() => codegen.ascTypeForEthereum('bytes0[][]')).toThrow();
|
|
256
|
-
expect(() => codegen.ascTypeForEthereum('bytes0[83][]')).toThrow();
|
|
257
|
-
expect(() => codegen.ascTypeForEthereum('bytes0[][83]')).toThrow();
|
|
258
|
-
expect(() => codegen.ascTypeForEthereum('bytes0[123][321]')).toThrow();
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
test('bytes1..32[*][*] -> Array<Array<Bytes>>', () => {
|
|
262
|
-
for (let i = 1; i <= 32; i++) {
|
|
263
|
-
expect(codegen.ethereumToAsc('x', `bytes${i}[][]`)).toBe('x.toBytesMatrix()');
|
|
264
|
-
expect(codegen.ethereumToAsc('x', `bytes${i}[7][]`)).toBe('x.toBytesMatrix()');
|
|
265
|
-
expect(codegen.ethereumToAsc('x', `bytes${i}[][7]`)).toBe('x.toBytesMatrix()');
|
|
266
|
-
expect(codegen.ethereumToAsc('x', `bytes${i}[432][234]`)).toBe('x.toBytesMatrix()');
|
|
267
|
-
|
|
268
|
-
expect(codegen.ascTypeForEthereum(`bytes${i}[][]`)).toBe('Array<Array<Bytes>>');
|
|
269
|
-
expect(codegen.ascTypeForEthereum(`bytes${i}[6][]`)).toBe('Array<Array<Bytes>>');
|
|
270
|
-
expect(codegen.ascTypeForEthereum(`bytes${i}[][7]`)).toBe('Array<Array<Bytes>>');
|
|
271
|
-
expect(codegen.ascTypeForEthereum(`bytes${i}[432][234]`)).toBe('Array<Array<Bytes>>');
|
|
272
|
-
}
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
test('bytes33[*][*] (invalid)', () => {
|
|
276
|
-
expect(() => codegen.ethereumToAsc('x', 'bytes33[][]')).toThrow();
|
|
277
|
-
expect(() => codegen.ethereumToAsc('x', 'bytes33[58][]')).toThrow();
|
|
278
|
-
expect(() => codegen.ethereumToAsc('x', 'bytes33[][85]')).toThrow();
|
|
279
|
-
expect(() => codegen.ethereumToAsc('x', 'bytes33[394][493]')).toThrow();
|
|
280
|
-
|
|
281
|
-
expect(() => codegen.ascTypeForEthereum('bytes33[][]')).toThrow();
|
|
282
|
-
expect(() => codegen.ascTypeForEthereum('bytes33[58][]')).toThrow();
|
|
283
|
-
expect(() => codegen.ascTypeForEthereum('bytes33[][85]')).toThrow();
|
|
284
|
-
expect(() => codegen.ascTypeForEthereum('bytes33[394][493]')).toThrow();
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
test('int8..32[*][*], uint8..24[*][*] -> Array<Array<i32>>', () => {
|
|
288
|
-
for (let i = 8; i <= 32; i += 8) {
|
|
289
|
-
expect(codegen.ethereumToAsc('x', `int${i}[][]`)).toBe('x.toI32Matrix()');
|
|
290
|
-
expect(codegen.ethereumToAsc('x', `int${i}[6][]`)).toBe('x.toI32Matrix()');
|
|
291
|
-
expect(codegen.ethereumToAsc('x', `int${i}[][6]`)).toBe('x.toI32Matrix()');
|
|
292
|
-
expect(codegen.ethereumToAsc('x', `int${i}[4638][8364]`)).toBe('x.toI32Matrix()');
|
|
293
|
-
|
|
294
|
-
expect(codegen.ascTypeForEthereum(`int${i}[][]`)).toBe('Array<Array<i32>>');
|
|
295
|
-
expect(codegen.ascTypeForEthereum(`int${i}[6][]`)).toBe('Array<Array<i32>>');
|
|
296
|
-
expect(codegen.ascTypeForEthereum(`int${i}[][6]`)).toBe('Array<Array<i32>>');
|
|
297
|
-
expect(codegen.ascTypeForEthereum(`int${i}[4638][8364]`)).toBe('Array<Array<i32>>');
|
|
298
|
-
}
|
|
299
|
-
for (let i = 8; i <= 24; i += 8) {
|
|
300
|
-
expect(codegen.ethereumToAsc('x', `uint${i}[][]`)).toBe('x.toI32Matrix()');
|
|
301
|
-
expect(codegen.ethereumToAsc('x', `uint${i}[6][]`)).toBe('x.toI32Matrix()');
|
|
302
|
-
expect(codegen.ethereumToAsc('x', `uint${i}[][6]`)).toBe('x.toI32Matrix()');
|
|
303
|
-
expect(codegen.ethereumToAsc('x', `uint${i}[593][395]`)).toBe('x.toI32Matrix()');
|
|
304
|
-
|
|
305
|
-
expect(codegen.ascTypeForEthereum(`uint${i}[][]`)).toBe('Array<Array<i32>>');
|
|
306
|
-
expect(codegen.ascTypeForEthereum(`uint${i}[6][]`)).toBe('Array<Array<i32>>');
|
|
307
|
-
expect(codegen.ascTypeForEthereum(`uint${i}[][6]`)).toBe('Array<Array<i32>>');
|
|
308
|
-
expect(codegen.ascTypeForEthereum(`uint${i}[593][395]`)).toBe('Array<Array<i32>>');
|
|
309
|
-
}
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
test('uint32[*][*] -> Array<Array<BigInt>>', () => {
|
|
313
|
-
expect(codegen.ethereumToAsc('x', `uint32[][]`)).toBe('x.toBigIntMatrix()');
|
|
314
|
-
expect(codegen.ethereumToAsc('x', `uint32[6][]`)).toBe('x.toBigIntMatrix()');
|
|
315
|
-
expect(codegen.ethereumToAsc('x', `uint32[][6]`)).toBe('x.toBigIntMatrix()');
|
|
316
|
-
expect(codegen.ethereumToAsc('x', `uint32[593][395]`)).toBe('x.toBigIntMatrix()');
|
|
317
|
-
|
|
318
|
-
expect(codegen.ascTypeForEthereum(`uint32[][]`)).toBe('Array<Array<BigInt>>');
|
|
319
|
-
expect(codegen.ascTypeForEthereum(`uint32[6][]`)).toBe('Array<Array<BigInt>>');
|
|
320
|
-
expect(codegen.ascTypeForEthereum(`uint32[][5]`)).toBe('Array<Array<BigInt>>');
|
|
321
|
-
expect(codegen.ascTypeForEthereum(`uint32[593][395]`)).toBe('Array<Array<BigInt>>');
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
test('(u)int40..256[*][*] -> Array<Array<BigInt>>', () => {
|
|
325
|
-
for (let i = 40; i <= 256; i += 8) {
|
|
326
|
-
expect(codegen.ethereumToAsc('x', `int${i}[][]`)).toBe('x.toBigIntMatrix()');
|
|
327
|
-
expect(codegen.ethereumToAsc('x', `int${i}[7][]`)).toBe('x.toBigIntMatrix()');
|
|
328
|
-
expect(codegen.ethereumToAsc('x', `int${i}[][7]`)).toBe('x.toBigIntMatrix()');
|
|
329
|
-
expect(codegen.ethereumToAsc('x', `int${i}[6833][3386]`)).toBe('x.toBigIntMatrix()');
|
|
330
|
-
|
|
331
|
-
expect(codegen.ascTypeForEthereum(`int${i}[][]`)).toBe('Array<Array<BigInt>>');
|
|
332
|
-
expect(codegen.ascTypeForEthereum(`int${i}[7][]`)).toBe('Array<Array<BigInt>>');
|
|
333
|
-
expect(codegen.ascTypeForEthereum(`int${i}[][7]`)).toBe('Array<Array<BigInt>>');
|
|
334
|
-
expect(codegen.ascTypeForEthereum(`int${i}[6833][3386]`)).toBe('Array<Array<BigInt>>');
|
|
335
|
-
|
|
336
|
-
expect(codegen.ethereumToAsc('x', `uint${i}[][]`)).toBe('x.toBigIntMatrix()');
|
|
337
|
-
expect(codegen.ethereumToAsc('x', `uint${i}[23][]`)).toBe('x.toBigIntMatrix()');
|
|
338
|
-
expect(codegen.ethereumToAsc('x', `uint${i}[][32]`)).toBe('x.toBigIntMatrix()');
|
|
339
|
-
expect(codegen.ethereumToAsc('x', `uint${i}[467][764]`)).toBe('x.toBigIntMatrix()');
|
|
340
|
-
|
|
341
|
-
expect(codegen.ascTypeForEthereum(`uint${i}[][]`)).toBe('Array<Array<BigInt>>');
|
|
342
|
-
expect(codegen.ascTypeForEthereum(`uint${i}[23][]`)).toBe('Array<Array<BigInt>>');
|
|
343
|
-
expect(codegen.ascTypeForEthereum(`uint${i}[][32]`)).toBe('Array<Array<BigInt>>');
|
|
344
|
-
expect(codegen.ascTypeForEthereum(`uint${i}[467][764]`)).toBe('Array<Array<BigInt>>');
|
|
345
|
-
}
|
|
346
|
-
});
|
|
347
|
-
|
|
348
|
-
test('string[*][*] -> Array<Array<string>>', () => {
|
|
349
|
-
expect(codegen.ethereumToAsc('x', 'string[][]')).toBe('x.toStringMatrix()');
|
|
350
|
-
expect(codegen.ethereumToAsc('x', 'string[4][]')).toBe('x.toStringMatrix()');
|
|
351
|
-
expect(codegen.ethereumToAsc('x', 'string[][3]')).toBe('x.toStringMatrix()');
|
|
352
|
-
expect(codegen.ethereumToAsc('x', 'string[754][457]')).toBe('x.toStringMatrix()');
|
|
353
|
-
|
|
354
|
-
expect(codegen.ascTypeForEthereum('string[][]')).toBe('Array<Array<string>>');
|
|
355
|
-
expect(codegen.ascTypeForEthereum('string[4][]')).toBe('Array<Array<string>>');
|
|
356
|
-
expect(codegen.ascTypeForEthereum('string[][3]')).toBe('Array<Array<string>>');
|
|
357
|
-
expect(codegen.ascTypeForEthereum('string[754][457]')).toBe('Array<Array<string>>');
|
|
358
|
-
});
|
|
359
|
-
});
|
|
360
|
-
|
|
361
|
-
describe('AssemblyScript -> ethereum.Value', () => {
|
|
362
|
-
// Scalar values
|
|
363
|
-
|
|
364
|
-
test('Address -> address', () => {
|
|
365
|
-
expect(codegen.ethereumFromAsc('x', 'address')).toBe('ethereum.Value.fromAddress(x)');
|
|
366
|
-
});
|
|
367
|
-
|
|
368
|
-
test('boolean -> bool', () => {
|
|
369
|
-
expect(codegen.ethereumFromAsc('x', 'bool')).toBe('ethereum.Value.fromBoolean(x)');
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
test('Bytes -> byte', () => {
|
|
373
|
-
expect(codegen.ethereumFromAsc('x', 'byte')).toBe('ethereum.Value.fromFixedBytes(x)');
|
|
374
|
-
});
|
|
375
|
-
|
|
376
|
-
test('Bytes -> bytes', () => {
|
|
377
|
-
expect(codegen.ethereumFromAsc('x', 'bytes')).toBe('ethereum.Value.fromBytes(x)');
|
|
378
|
-
});
|
|
379
|
-
|
|
380
|
-
test('Bytes -> bytes0 (invalid)', () => {
|
|
381
|
-
expect(() => codegen.ethereumFromAsc('x', 'bytes0')).toThrow();
|
|
382
|
-
});
|
|
383
|
-
|
|
384
|
-
test('Bytes -> bytes1..32', () => {
|
|
385
|
-
for (let i = 1; i <= 32; i++) {
|
|
386
|
-
expect(codegen.ethereumFromAsc('x', `bytes${i}`)).toBe('ethereum.Value.fromFixedBytes(x)');
|
|
387
|
-
}
|
|
388
|
-
});
|
|
389
|
-
|
|
390
|
-
test('Bytes -> bytes33 (invalid)', () => {
|
|
391
|
-
expect(() => codegen.ethereumFromAsc('x', 'bytes33')).toThrow();
|
|
392
|
-
});
|
|
393
|
-
|
|
394
|
-
test('i32 -> int8..32, uint8..24', () => {
|
|
395
|
-
for (let i = 8; i <= 32; i += 8) {
|
|
396
|
-
expect(codegen.ethereumFromAsc('x', `int${i}`)).toBe(`ethereum.Value.fromI32(x)`);
|
|
397
|
-
}
|
|
398
|
-
for (let i = 8; i <= 24; i += 8) {
|
|
399
|
-
expect(codegen.ethereumFromAsc('x', `uint${i}`)).toBe(
|
|
400
|
-
`ethereum.Value.fromUnsignedBigInt(BigInt.fromI32(x))`,
|
|
401
|
-
);
|
|
402
|
-
}
|
|
403
|
-
});
|
|
404
|
-
|
|
405
|
-
test('BigInt -> uint32', () => {
|
|
406
|
-
expect(codegen.ethereumFromAsc('x', `uint32`)).toBe(`ethereum.Value.fromUnsignedBigInt(x)`);
|
|
407
|
-
});
|
|
408
|
-
|
|
409
|
-
test('BigInt -> (u)int40..256', () => {
|
|
410
|
-
for (let i = 40; i <= 256; i += 8) {
|
|
411
|
-
expect(codegen.ethereumFromAsc('x', `int${i}`)).toBe(`ethereum.Value.fromSignedBigInt(x)`);
|
|
412
|
-
expect(codegen.ethereumFromAsc('x', `uint${i}`)).toBe(`ethereum.Value.fromUnsignedBigInt(x)`);
|
|
413
|
-
}
|
|
414
|
-
});
|
|
415
|
-
|
|
416
|
-
test('String -> string', () => {
|
|
417
|
-
expect(codegen.ethereumFromAsc('x', 'string')).toBe('ethereum.Value.fromString(x)');
|
|
418
|
-
});
|
|
419
|
-
|
|
420
|
-
// Array values
|
|
421
|
-
|
|
422
|
-
test('Array<Address> -> address[*]', () => {
|
|
423
|
-
expect(codegen.ethereumFromAsc('x', 'address[]')).toBe('ethereum.Value.fromAddressArray(x)');
|
|
424
|
-
expect(codegen.ethereumFromAsc('x', 'address[1]')).toBe('ethereum.Value.fromAddressArray(x)');
|
|
425
|
-
expect(codegen.ethereumFromAsc('x', 'address[123]')).toBe('ethereum.Value.fromAddressArray(x)');
|
|
426
|
-
});
|
|
427
|
-
|
|
428
|
-
test('Array<boolean> -> bool[*]', () => {
|
|
429
|
-
expect(codegen.ethereumFromAsc('x', 'bool[]')).toBe('ethereum.Value.fromBooleanArray(x)');
|
|
430
|
-
expect(codegen.ethereumFromAsc('x', 'bool[5]')).toBe('ethereum.Value.fromBooleanArray(x)');
|
|
431
|
-
expect(codegen.ethereumFromAsc('x', 'bool[275]')).toBe('ethereum.Value.fromBooleanArray(x)');
|
|
432
|
-
});
|
|
433
|
-
|
|
434
|
-
test('Array<Bytes> -> byte[*]', () => {
|
|
435
|
-
expect(codegen.ethereumFromAsc('x', 'byte[]')).toBe('ethereum.Value.fromFixedBytesArray(x)');
|
|
436
|
-
expect(codegen.ethereumFromAsc('x', 'byte[7]')).toBe('ethereum.Value.fromFixedBytesArray(x)');
|
|
437
|
-
expect(codegen.ethereumFromAsc('x', 'byte[553]')).toBe('ethereum.Value.fromFixedBytesArray(x)');
|
|
438
|
-
});
|
|
439
|
-
|
|
440
|
-
test('Array<Bytes> -> bytes[*]', () => {
|
|
441
|
-
expect(codegen.ethereumFromAsc('x', 'bytes[]')).toBe('ethereum.Value.fromBytesArray(x)');
|
|
442
|
-
expect(codegen.ethereumFromAsc('x', 'bytes[14]')).toBe('ethereum.Value.fromBytesArray(x)');
|
|
443
|
-
expect(codegen.ethereumFromAsc('x', 'bytes[444]')).toBe('ethereum.Value.fromBytesArray(x)');
|
|
444
|
-
});
|
|
445
|
-
|
|
446
|
-
test('bytes0[*] (invalid)', () => {
|
|
447
|
-
expect(() => codegen.ethereumFromAsc('x', 'bytes0[]')).toThrow();
|
|
448
|
-
expect(() => codegen.ethereumFromAsc('x', 'bytes0[83]')).toThrow();
|
|
449
|
-
expect(() => codegen.ethereumFromAsc('x', 'bytes0[123]')).toThrow();
|
|
450
|
-
});
|
|
451
|
-
|
|
452
|
-
test('Array<Bytes> -> bytes1..32[*]', () => {
|
|
453
|
-
for (let i = 1; i <= 32; i++) {
|
|
454
|
-
expect(codegen.ethereumFromAsc('x', `bytes${i}[]`)).toBe(
|
|
455
|
-
'ethereum.Value.fromFixedBytesArray(x)',
|
|
456
|
-
);
|
|
457
|
-
expect(codegen.ethereumFromAsc('x', `bytes${i}[7]`)).toBe(
|
|
458
|
-
'ethereum.Value.fromFixedBytesArray(x)',
|
|
459
|
-
);
|
|
460
|
-
expect(codegen.ethereumFromAsc('x', `bytes${i}[432]`)).toBe(
|
|
461
|
-
'ethereum.Value.fromFixedBytesArray(x)',
|
|
462
|
-
);
|
|
463
|
-
}
|
|
464
|
-
});
|
|
465
|
-
|
|
466
|
-
test('bytes33[*] (invalid)', () => {
|
|
467
|
-
expect(() => codegen.ethereumFromAsc('x', 'bytes33[]')).toThrow();
|
|
468
|
-
expect(() => codegen.ethereumFromAsc('x', 'bytes33[58]')).toThrow();
|
|
469
|
-
expect(() => codegen.ethereumFromAsc('x', 'bytes33[394]')).toThrow();
|
|
470
|
-
});
|
|
471
|
-
|
|
472
|
-
test('Array<i32> -> int8..32[*], uint8..24[*]', () => {
|
|
473
|
-
for (let i = 8; i <= 32; i += 8) {
|
|
474
|
-
expect(codegen.ethereumFromAsc('x', `int${i}[]`)).toBe('ethereum.Value.fromI32Array(x)');
|
|
475
|
-
expect(codegen.ethereumFromAsc('x', `int${i}[6]`)).toBe('ethereum.Value.fromI32Array(x)');
|
|
476
|
-
expect(codegen.ethereumFromAsc('x', `int${i}[4638]`)).toBe('ethereum.Value.fromI32Array(x)');
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
for (let i = 8; i <= 24; i += 8) {
|
|
480
|
-
expect(codegen.ethereumFromAsc('x', `uint${i}[]`)).toBe('ethereum.Value.fromI32Array(x)');
|
|
481
|
-
expect(codegen.ethereumFromAsc('x', `uint${i}[6]`)).toBe('ethereum.Value.fromI32Array(x)');
|
|
482
|
-
expect(codegen.ethereumFromAsc('x', `uint${i}[593]`)).toBe('ethereum.Value.fromI32Array(x)');
|
|
483
|
-
}
|
|
484
|
-
});
|
|
485
|
-
|
|
486
|
-
test('Array<BigInt> -> uint32[*]', () => {
|
|
487
|
-
expect(codegen.ethereumFromAsc('x', `uint32[]`)).toBe(
|
|
488
|
-
'ethereum.Value.fromUnsignedBigIntArray(x)',
|
|
489
|
-
);
|
|
490
|
-
expect(codegen.ethereumFromAsc('x', `uint32[6]`)).toBe(
|
|
491
|
-
'ethereum.Value.fromUnsignedBigIntArray(x)',
|
|
492
|
-
);
|
|
493
|
-
expect(codegen.ethereumFromAsc('x', `uint32[593]`)).toBe(
|
|
494
|
-
'ethereum.Value.fromUnsignedBigIntArray(x)',
|
|
495
|
-
);
|
|
496
|
-
});
|
|
497
|
-
|
|
498
|
-
test('Array<BigInt> -> (u)int40..256[*]', () => {
|
|
499
|
-
for (let i = 40; i <= 256; i += 8) {
|
|
500
|
-
expect(codegen.ethereumFromAsc('x', `int${i}[]`)).toBe(
|
|
501
|
-
'ethereum.Value.fromSignedBigIntArray(x)',
|
|
502
|
-
);
|
|
503
|
-
expect(codegen.ethereumFromAsc('x', `int${i}[7]`)).toBe(
|
|
504
|
-
'ethereum.Value.fromSignedBigIntArray(x)',
|
|
505
|
-
);
|
|
506
|
-
expect(codegen.ethereumFromAsc('x', `int${i}[6833]`)).toBe(
|
|
507
|
-
'ethereum.Value.fromSignedBigIntArray(x)',
|
|
508
|
-
);
|
|
509
|
-
|
|
510
|
-
expect(codegen.ethereumFromAsc('x', `uint${i}[]`)).toBe(
|
|
511
|
-
'ethereum.Value.fromUnsignedBigIntArray(x)',
|
|
512
|
-
);
|
|
513
|
-
expect(codegen.ethereumFromAsc('x', `uint${i}[23]`)).toBe(
|
|
514
|
-
'ethereum.Value.fromUnsignedBigIntArray(x)',
|
|
515
|
-
);
|
|
516
|
-
expect(codegen.ethereumFromAsc('x', `uint${i}[467]`)).toBe(
|
|
517
|
-
'ethereum.Value.fromUnsignedBigIntArray(x)',
|
|
518
|
-
);
|
|
519
|
-
}
|
|
520
|
-
});
|
|
521
|
-
|
|
522
|
-
test('Array<String> -> string[*]', () => {
|
|
523
|
-
expect(codegen.ethereumFromAsc('x', 'string[]')).toBe('ethereum.Value.fromStringArray(x)');
|
|
524
|
-
expect(codegen.ethereumFromAsc('x', 'string[4]')).toBe('ethereum.Value.fromStringArray(x)');
|
|
525
|
-
expect(codegen.ethereumFromAsc('x', 'string[754]')).toBe('ethereum.Value.fromStringArray(x)');
|
|
526
|
-
});
|
|
527
|
-
|
|
528
|
-
// Multidimensional arrays
|
|
529
|
-
|
|
530
|
-
test('Array<Array<Address>> -> address[*][*]', () => {
|
|
531
|
-
expect(codegen.ethereumFromAsc('x', 'address[][]')).toBe('ethereum.Value.fromAddressMatrix(x)');
|
|
532
|
-
expect(codegen.ethereumFromAsc('x', 'address[1][]')).toBe(
|
|
533
|
-
'ethereum.Value.fromAddressMatrix(x)',
|
|
534
|
-
);
|
|
535
|
-
expect(codegen.ethereumFromAsc('x', 'address[][2]')).toBe(
|
|
536
|
-
'ethereum.Value.fromAddressMatrix(x)',
|
|
537
|
-
);
|
|
538
|
-
expect(codegen.ethereumFromAsc('x', 'address[123][321]')).toBe(
|
|
539
|
-
'ethereum.Value.fromAddressMatrix(x)',
|
|
540
|
-
);
|
|
541
|
-
});
|
|
542
|
-
|
|
543
|
-
test('Array<Array<boolean>> -> bool[*][*]', () => {
|
|
544
|
-
expect(codegen.ethereumFromAsc('x', 'bool[][]')).toBe('ethereum.Value.fromBooleanMatrix(x)');
|
|
545
|
-
expect(codegen.ethereumFromAsc('x', 'bool[5][]')).toBe('ethereum.Value.fromBooleanMatrix(x)');
|
|
546
|
-
expect(codegen.ethereumFromAsc('x', 'bool[][5]')).toBe('ethereum.Value.fromBooleanMatrix(x)');
|
|
547
|
-
expect(codegen.ethereumFromAsc('x', 'bool[275][572]')).toBe(
|
|
548
|
-
'ethereum.Value.fromBooleanMatrix(x)',
|
|
549
|
-
);
|
|
550
|
-
});
|
|
551
|
-
|
|
552
|
-
test('Array<Array<Bytes>> -> byte[*][*]', () => {
|
|
553
|
-
expect(codegen.ethereumFromAsc('x', 'byte[][]')).toBe('ethereum.Value.fromFixedBytesMatrix(x)');
|
|
554
|
-
expect(codegen.ethereumFromAsc('x', 'byte[7][]')).toBe(
|
|
555
|
-
'ethereum.Value.fromFixedBytesMatrix(x)',
|
|
556
|
-
);
|
|
557
|
-
expect(codegen.ethereumFromAsc('x', 'byte[][6]')).toBe(
|
|
558
|
-
'ethereum.Value.fromFixedBytesMatrix(x)',
|
|
559
|
-
);
|
|
560
|
-
expect(codegen.ethereumFromAsc('x', 'byte[553][355]')).toBe(
|
|
561
|
-
'ethereum.Value.fromFixedBytesMatrix(x)',
|
|
562
|
-
);
|
|
563
|
-
});
|
|
564
|
-
|
|
565
|
-
test('Array<Array<Bytes>> -> bytes[*][*]', () => {
|
|
566
|
-
expect(codegen.ethereumFromAsc('x', 'bytes[][]')).toBe('ethereum.Value.fromBytesMatrix(x)');
|
|
567
|
-
expect(codegen.ethereumFromAsc('x', 'bytes[14][]')).toBe('ethereum.Value.fromBytesMatrix(x)');
|
|
568
|
-
expect(codegen.ethereumFromAsc('x', 'bytes[][41]')).toBe('ethereum.Value.fromBytesMatrix(x)');
|
|
569
|
-
expect(codegen.ethereumFromAsc('x', 'bytes[444][333]')).toBe(
|
|
570
|
-
'ethereum.Value.fromBytesMatrix(x)',
|
|
571
|
-
);
|
|
572
|
-
});
|
|
573
|
-
|
|
574
|
-
test('bytes0[*][*] (invalid)', () => {
|
|
575
|
-
expect(() => codegen.ethereumFromAsc('x', 'bytes0[][]')).toThrow();
|
|
576
|
-
expect(() => codegen.ethereumFromAsc('x', 'bytes0[83][]')).toThrow();
|
|
577
|
-
expect(() => codegen.ethereumFromAsc('x', 'bytes0[][38]')).toThrow();
|
|
578
|
-
expect(() => codegen.ethereumFromAsc('x', 'bytes0[123][321]')).toThrow();
|
|
579
|
-
});
|
|
580
|
-
|
|
581
|
-
test('Array<Array<Bytes>> -> bytes1..32[*][*]', () => {
|
|
582
|
-
for (let i = 1; i <= 32; i++) {
|
|
583
|
-
expect(codegen.ethereumFromAsc('x', `bytes${i}[][]`)).toBe(
|
|
584
|
-
'ethereum.Value.fromFixedBytesMatrix(x)',
|
|
585
|
-
);
|
|
586
|
-
expect(codegen.ethereumFromAsc('x', `bytes${i}[7][]`)).toBe(
|
|
587
|
-
'ethereum.Value.fromFixedBytesMatrix(x)',
|
|
588
|
-
);
|
|
589
|
-
expect(codegen.ethereumFromAsc('x', `bytes${i}[][7]`)).toBe(
|
|
590
|
-
'ethereum.Value.fromFixedBytesMatrix(x)',
|
|
591
|
-
);
|
|
592
|
-
expect(codegen.ethereumFromAsc('x', `bytes${i}[432][234]`)).toBe(
|
|
593
|
-
'ethereum.Value.fromFixedBytesMatrix(x)',
|
|
594
|
-
);
|
|
595
|
-
}
|
|
596
|
-
});
|
|
597
|
-
|
|
598
|
-
test('bytes33[*][*] (invalid)', () => {
|
|
599
|
-
expect(() => codegen.ethereumFromAsc('x', 'bytes33[][]')).toThrow();
|
|
600
|
-
expect(() => codegen.ethereumFromAsc('x', 'bytes33[58][]')).toThrow();
|
|
601
|
-
expect(() => codegen.ethereumFromAsc('x', 'bytes33[][85]')).toThrow();
|
|
602
|
-
expect(() => codegen.ethereumFromAsc('x', 'bytes33[394][493]')).toThrow();
|
|
603
|
-
});
|
|
604
|
-
|
|
605
|
-
test('Array<Array<i32>> -> int8..32[*][*], uint8..24[*][*]', () => {
|
|
606
|
-
for (let i = 8; i <= 32; i += 8) {
|
|
607
|
-
expect(codegen.ethereumFromAsc('x', `int${i}[][]`)).toBe('ethereum.Value.fromI32Matrix(x)');
|
|
608
|
-
expect(codegen.ethereumFromAsc('x', `int${i}[6][]`)).toBe('ethereum.Value.fromI32Matrix(x)');
|
|
609
|
-
expect(codegen.ethereumFromAsc('x', `int${i}[][5]`)).toBe('ethereum.Value.fromI32Matrix(x)');
|
|
610
|
-
expect(codegen.ethereumFromAsc('x', `int${i}[4638][8364]`)).toBe(
|
|
611
|
-
'ethereum.Value.fromI32Matrix(x)',
|
|
612
|
-
);
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
for (let i = 8; i <= 24; i += 8) {
|
|
616
|
-
expect(codegen.ethereumFromAsc('x', `uint${i}[][]`)).toBe('ethereum.Value.fromI32Matrix(x)');
|
|
617
|
-
expect(codegen.ethereumFromAsc('x', `uint${i}[6][]`)).toBe('ethereum.Value.fromI32Matrix(x)');
|
|
618
|
-
expect(codegen.ethereumFromAsc('x', `uint${i}[][5]`)).toBe('ethereum.Value.fromI32Matrix(x)');
|
|
619
|
-
expect(codegen.ethereumFromAsc('x', `uint${i}[593][395]`)).toBe(
|
|
620
|
-
'ethereum.Value.fromI32Matrix(x)',
|
|
621
|
-
);
|
|
622
|
-
}
|
|
623
|
-
});
|
|
624
|
-
|
|
625
|
-
test('Array<Array<BigInt>> -> uint32[*][*]', () => {
|
|
626
|
-
expect(codegen.ethereumFromAsc('x', `uint32[][]`)).toBe(
|
|
627
|
-
'ethereum.Value.fromUnsignedBigIntMatrix(x)',
|
|
628
|
-
);
|
|
629
|
-
expect(codegen.ethereumFromAsc('x', `uint32[6][]`)).toBe(
|
|
630
|
-
'ethereum.Value.fromUnsignedBigIntMatrix(x)',
|
|
631
|
-
);
|
|
632
|
-
expect(codegen.ethereumFromAsc('x', `uint32[][5]`)).toBe(
|
|
633
|
-
'ethereum.Value.fromUnsignedBigIntMatrix(x)',
|
|
634
|
-
);
|
|
635
|
-
expect(codegen.ethereumFromAsc('x', `uint32[593][395]`)).toBe(
|
|
636
|
-
'ethereum.Value.fromUnsignedBigIntMatrix(x)',
|
|
637
|
-
);
|
|
638
|
-
});
|
|
639
|
-
|
|
640
|
-
test('Array<Array<BigInt>> -> (u)int40..256[*][*]', () => {
|
|
641
|
-
for (let i = 40; i <= 256; i += 8) {
|
|
642
|
-
expect(codegen.ethereumFromAsc('x', `int${i}[][]`)).toBe(
|
|
643
|
-
'ethereum.Value.fromSignedBigIntMatrix(x)',
|
|
644
|
-
);
|
|
645
|
-
expect(codegen.ethereumFromAsc('x', `int${i}[8][]`)).toBe(
|
|
646
|
-
'ethereum.Value.fromSignedBigIntMatrix(x)',
|
|
647
|
-
);
|
|
648
|
-
expect(codegen.ethereumFromAsc('x', `int${i}[][7]`)).toBe(
|
|
649
|
-
'ethereum.Value.fromSignedBigIntMatrix(x)',
|
|
650
|
-
);
|
|
651
|
-
expect(codegen.ethereumFromAsc('x', `int${i}[6833][3386]`)).toBe(
|
|
652
|
-
'ethereum.Value.fromSignedBigIntMatrix(x)',
|
|
653
|
-
);
|
|
654
|
-
|
|
655
|
-
expect(codegen.ethereumFromAsc('x', `uint${i}[][]`)).toBe(
|
|
656
|
-
'ethereum.Value.fromUnsignedBigIntMatrix(x)',
|
|
657
|
-
);
|
|
658
|
-
expect(codegen.ethereumFromAsc('x', `uint${i}[23][]`)).toBe(
|
|
659
|
-
'ethereum.Value.fromUnsignedBigIntMatrix(x)',
|
|
660
|
-
);
|
|
661
|
-
expect(codegen.ethereumFromAsc('x', `uint${i}[][32]`)).toBe(
|
|
662
|
-
'ethereum.Value.fromUnsignedBigIntMatrix(x)',
|
|
663
|
-
);
|
|
664
|
-
expect(codegen.ethereumFromAsc('x', `uint${i}[467][764]`)).toBe(
|
|
665
|
-
'ethereum.Value.fromUnsignedBigIntMatrix(x)',
|
|
666
|
-
);
|
|
667
|
-
}
|
|
668
|
-
});
|
|
669
|
-
|
|
670
|
-
test('Array<Array<String>> -> string[*][*]', () => {
|
|
671
|
-
expect(codegen.ethereumFromAsc('x', 'string[]')).toBe('ethereum.Value.fromStringArray(x)');
|
|
672
|
-
expect(codegen.ethereumFromAsc('x', 'string[4]')).toBe('ethereum.Value.fromStringArray(x)');
|
|
673
|
-
expect(codegen.ethereumFromAsc('x', 'string[754]')).toBe('ethereum.Value.fromStringArray(x)');
|
|
674
|
-
});
|
|
675
|
-
});
|
|
676
|
-
|
|
677
|
-
describe('Value -> AssemblyScript', () => {
|
|
678
|
-
test('BigDecimal -> BigDecimal', () => {
|
|
679
|
-
expect(codegen.valueToAsc('x', 'BigDecimal')).toBe('x.toBigDecimal()');
|
|
680
|
-
});
|
|
681
|
-
|
|
682
|
-
test('[BigDecimal] -> Array<BigDecimal>', () => {
|
|
683
|
-
expect(codegen.valueToAsc('x', '[BigDecimal]')).toBe('x.toBigDecimalArray()');
|
|
684
|
-
});
|
|
685
|
-
|
|
686
|
-
test('String -> string', () => {
|
|
687
|
-
expect(codegen.valueToAsc('x', 'string')).toBe('x.toString()');
|
|
688
|
-
});
|
|
689
|
-
|
|
690
|
-
test('[String] -> Array<string>', () => {
|
|
691
|
-
expect(codegen.valueToAsc('x', '[String]')).toBe('x.toStringArray()');
|
|
692
|
-
});
|
|
693
|
-
});
|
|
694
|
-
|
|
695
|
-
describe('AssemblyScript -> Value', () => {
|
|
696
|
-
test('BigDecimal -> BigDecimal', () => {
|
|
697
|
-
expect(codegen.valueFromAsc('x', 'BigDecimal')).toBe('Value.fromBigDecimal(x)');
|
|
698
|
-
expect(codegen.valueTypeForAsc('BigDecimal')).toBe('BigDecimal');
|
|
699
|
-
});
|
|
700
|
-
|
|
701
|
-
test('Array<BigDecimal> -> [BigDecimal]', () => {
|
|
702
|
-
expect(codegen.valueFromAsc('x', '[BigDecimal]')).toBe('Value.fromBigDecimalArray(x)');
|
|
703
|
-
expect(codegen.valueTypeForAsc('Array<BigDecimal>')).toBe('[BigDecimal]');
|
|
704
|
-
});
|
|
705
|
-
|
|
706
|
-
test('string -> String', () => {
|
|
707
|
-
expect(codegen.valueFromAsc('x', 'String')).toBe('Value.fromString(x)');
|
|
708
|
-
expect(codegen.valueTypeForAsc('string')).toBe('String');
|
|
709
|
-
});
|
|
710
|
-
|
|
711
|
-
test('Array<string> -> [String]', () => {
|
|
712
|
-
expect(codegen.valueFromAsc('x', '[String]')).toBe('Value.fromStringArray(x)');
|
|
713
|
-
expect(codegen.valueTypeForAsc('Array<string>')).toBe('[String]');
|
|
714
|
-
});
|
|
715
|
-
});
|