tempo.ts 0.1.0 → 0.1.2
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/package.json +17 -18
- package/src/ox/TokenId.test.ts +11 -0
- package/src/ox/TokenId.ts +15 -0
- package/src/prool/Instance.ts +2 -2
- package/src/viem/Abis.ts +2 -1
- package/src/viem/Actions/dex.test.ts +15 -15
- package/src/viem/Actions/token.test.ts +34 -0
- package/src/viem/Actions/token.ts +81 -14
- package/src/viem/e2e.test.ts +11 -10
- package/dist/chains.d.ts +0 -1180
- package/dist/chains.d.ts.map +0 -1
- package/dist/chains.js +0 -30
- package/dist/chains.js.map +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +0 -1
- package/dist/internal/types.d.ts +0 -284
- package/dist/internal/types.d.ts.map +0 -1
- package/dist/internal/types.js +0 -2
- package/dist/internal/types.js.map +0 -1
- package/dist/ox/SignatureEnvelope.d.ts +0 -245
- package/dist/ox/SignatureEnvelope.d.ts.map +0 -1
- package/dist/ox/SignatureEnvelope.js +0 -437
- package/dist/ox/SignatureEnvelope.js.map +0 -1
- package/dist/ox/TokenId.d.ts +0 -18
- package/dist/ox/TokenId.d.ts.map +0 -1
- package/dist/ox/TokenId.js +0 -29
- package/dist/ox/TokenId.js.map +0 -1
- package/dist/ox/TokenRole.d.ts +0 -11
- package/dist/ox/TokenRole.d.ts.map +0 -1
- package/dist/ox/TokenRole.js +0 -22
- package/dist/ox/TokenRole.js.map +0 -1
- package/dist/ox/Transaction.d.ts +0 -198
- package/dist/ox/Transaction.d.ts.map +0 -1
- package/dist/ox/Transaction.js +0 -162
- package/dist/ox/Transaction.js.map +0 -1
- package/dist/ox/TransactionEnvelopeAA.d.ts +0 -461
- package/dist/ox/TransactionEnvelopeAA.d.ts.map +0 -1
- package/dist/ox/TransactionEnvelopeAA.js +0 -528
- package/dist/ox/TransactionEnvelopeAA.js.map +0 -1
- package/dist/ox/TransactionRequest.d.ts +0 -64
- package/dist/ox/TransactionRequest.d.ts.map +0 -1
- package/dist/ox/TransactionRequest.js +0 -75
- package/dist/ox/TransactionRequest.js.map +0 -1
- package/dist/ox/index.d.ts +0 -6
- package/dist/ox/index.d.ts.map +0 -1
- package/dist/ox/index.js +0 -6
- package/dist/ox/index.js.map +0 -1
- package/dist/prool/Instance.d.ts +0 -88
- package/dist/prool/Instance.d.ts.map +0 -1
- package/dist/prool/Instance.js +0 -96
- package/dist/prool/Instance.js.map +0 -1
- package/dist/prool/index.d.ts +0 -2
- package/dist/prool/index.d.ts.map +0 -1
- package/dist/prool/index.js +0 -2
- package/dist/prool/index.js.map +0 -1
- package/dist/viem/Abis.d.ts +0 -1881
- package/dist/viem/Abis.d.ts.map +0 -1
- package/dist/viem/Abis.js +0 -1173
- package/dist/viem/Abis.js.map +0 -1
- package/dist/viem/Actions/amm.d.ts +0 -2006
- package/dist/viem/Actions/amm.d.ts.map +0 -1
- package/dist/viem/Actions/amm.js +0 -900
- package/dist/viem/Actions/amm.js.map +0 -1
- package/dist/viem/Actions/dex.d.ts +0 -3263
- package/dist/viem/Actions/dex.d.ts.map +0 -1
- package/dist/viem/Actions/dex.js +0 -1357
- package/dist/viem/Actions/dex.js.map +0 -1
- package/dist/viem/Actions/fee.d.ts +0 -374
- package/dist/viem/Actions/fee.d.ts.map +0 -1
- package/dist/viem/Actions/fee.js +0 -235
- package/dist/viem/Actions/fee.js.map +0 -1
- package/dist/viem/Actions/index.d.ts +0 -6
- package/dist/viem/Actions/index.d.ts.map +0 -1
- package/dist/viem/Actions/index.js +0 -6
- package/dist/viem/Actions/index.js.map +0 -1
- package/dist/viem/Actions/policy.d.ts +0 -1672
- package/dist/viem/Actions/policy.d.ts.map +0 -1
- package/dist/viem/Actions/policy.js +0 -875
- package/dist/viem/Actions/policy.js.map +0 -1
- package/dist/viem/Actions/token.d.ts +0 -13687
- package/dist/viem/Actions/token.d.ts.map +0 -1
- package/dist/viem/Actions/token.js +0 -3020
- package/dist/viem/Actions/token.js.map +0 -1
- package/dist/viem/Addresses.d.ts +0 -9
- package/dist/viem/Addresses.d.ts.map +0 -1
- package/dist/viem/Addresses.js +0 -9
- package/dist/viem/Addresses.js.map +0 -1
- package/dist/viem/Chain.d.ts +0 -365
- package/dist/viem/Chain.d.ts.map +0 -1
- package/dist/viem/Chain.js +0 -22
- package/dist/viem/Chain.js.map +0 -1
- package/dist/viem/Client.d.ts +0 -27
- package/dist/viem/Client.d.ts.map +0 -1
- package/dist/viem/Client.js +0 -28
- package/dist/viem/Client.js.map +0 -1
- package/dist/viem/Decorator.d.ts +0 -2161
- package/dist/viem/Decorator.d.ts.map +0 -1
- package/dist/viem/Decorator.js +0 -122
- package/dist/viem/Decorator.js.map +0 -1
- package/dist/viem/Formatters.d.ts +0 -4
- package/dist/viem/Formatters.d.ts.map +0 -1
- package/dist/viem/Formatters.js +0 -76
- package/dist/viem/Formatters.js.map +0 -1
- package/dist/viem/Tick.d.ts +0 -111
- package/dist/viem/Tick.d.ts.map +0 -1
- package/dist/viem/Tick.js +0 -127
- package/dist/viem/Tick.js.map +0 -1
- package/dist/viem/TokenIds.d.ts +0 -3
- package/dist/viem/TokenIds.d.ts.map +0 -1
- package/dist/viem/TokenIds.js +0 -3
- package/dist/viem/TokenIds.js.map +0 -1
- package/dist/viem/Transaction.d.ts +0 -57
- package/dist/viem/Transaction.d.ts.map +0 -1
- package/dist/viem/Transaction.js +0 -137
- package/dist/viem/Transaction.js.map +0 -1
- package/dist/viem/Transport.d.ts +0 -16
- package/dist/viem/Transport.d.ts.map +0 -1
- package/dist/viem/Transport.js +0 -33
- package/dist/viem/Transport.js.map +0 -1
- package/dist/viem/index.d.ts +0 -14
- package/dist/viem/index.d.ts.map +0 -1
- package/dist/viem/index.js +0 -14
- package/dist/viem/index.js.map +0 -1
- package/dist/viem/internal/types.d.ts +0 -10
- package/dist/viem/internal/types.d.ts.map +0 -1
- package/dist/viem/internal/types.js +0 -2
- package/dist/viem/internal/types.js.map +0 -1
- package/dist/viem/internal/utils.d.ts +0 -8
- package/dist/viem/internal/utils.d.ts.map +0 -1
- package/dist/viem/internal/utils.js +0 -9
- package/dist/viem/internal/utils.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tempo.ts",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
5
|
-
"scripts": {
|
|
6
|
-
"build": "zile --project ./tsconfig.build.json",
|
|
7
|
-
"changeset:publish": "bun run build && changeset publish",
|
|
8
|
-
"changeset:version": "changeset version && bun run check",
|
|
9
|
-
"check": "biome check . --write --unsafe",
|
|
10
|
-
"check:types": "tsc -b",
|
|
11
|
-
"gen:abis": "bun scripts/gen:abis.ts && bun run check",
|
|
12
|
-
"submodules:pull": "git submodule foreach git pull origin main && pnpm gen:abis",
|
|
13
|
-
"test": "vitest",
|
|
14
|
-
"test:install": "cd test/tempo && cargo install --path bin/tempo && cargo run --bin tempo-bench generate-genesis --accounts 1 --output ../../src/prool/internal/chain.json"
|
|
15
|
-
},
|
|
4
|
+
"version": "0.1.2",
|
|
16
5
|
"dependencies": {
|
|
17
6
|
"ox": "~0.9.9"
|
|
18
7
|
},
|
|
@@ -28,7 +17,6 @@
|
|
|
28
17
|
"optional": true
|
|
29
18
|
}
|
|
30
19
|
},
|
|
31
|
-
"packageManager": "bun@1.3.0",
|
|
32
20
|
"author": "jxom <j@wevm.dev>",
|
|
33
21
|
"license": "MIT",
|
|
34
22
|
"devDependencies": {
|
|
@@ -36,16 +24,15 @@
|
|
|
36
24
|
"@biomejs/biome": "^2.2.4",
|
|
37
25
|
"@changesets/changelog-github": "^0.5.0",
|
|
38
26
|
"@changesets/cli": "^2.27.7",
|
|
39
|
-
"@
|
|
40
|
-
"@types/
|
|
27
|
+
"@remix-run/node-fetch-server": "^0.10.0",
|
|
28
|
+
"@types/node": "latest",
|
|
41
29
|
"@vitest/coverage-v8": "3.2.4",
|
|
42
|
-
"elysia": "latest",
|
|
43
30
|
"prool": "latest",
|
|
44
31
|
"simple-git-hooks": "^2.13.1",
|
|
45
32
|
"typescript": "^5.9.2",
|
|
46
33
|
"viem": "^2.38.2",
|
|
47
34
|
"vitest": "^3.2.4",
|
|
48
|
-
"zile": "^0.0.
|
|
35
|
+
"zile": "^0.0.3"
|
|
49
36
|
},
|
|
50
37
|
"files": [
|
|
51
38
|
"dist",
|
|
@@ -83,6 +70,18 @@
|
|
|
83
70
|
}
|
|
84
71
|
},
|
|
85
72
|
"simple-git-hooks": {
|
|
86
|
-
"pre-commit": "
|
|
73
|
+
"pre-commit": "pnpm check"
|
|
74
|
+
},
|
|
75
|
+
"scripts": {
|
|
76
|
+
"build": "zile --project ./tsconfig.build.json",
|
|
77
|
+
"changeset:publish": "pnpm build && changeset publish",
|
|
78
|
+
"changeset:version": "changeset version && pnpm check",
|
|
79
|
+
"check": "biome check . --write --unsafe",
|
|
80
|
+
"check:types": "tsc -b",
|
|
81
|
+
"gen:abis": "node scripts/gen:abis.ts && pnpm check",
|
|
82
|
+
"preconstruct": "zile dev --project ./tsconfig.build.json && pnpm check",
|
|
83
|
+
"submodules:pull": "git submodule foreach git pull origin main && pnpm gen:abis",
|
|
84
|
+
"test": "vitest",
|
|
85
|
+
"test:install": "cd test/tempo && cargo install --path bin/tempo && cargo run --bin tempo-bench generate-genesis --accounts 1 --output ../../src/prool/internal/chain.json"
|
|
87
86
|
}
|
|
88
87
|
}
|
package/src/ox/TokenId.test.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { TokenId } from 'tempo.ts/ox'
|
|
2
2
|
import { expect, test } from 'vitest'
|
|
3
3
|
|
|
4
|
+
test('from', () => {
|
|
5
|
+
expect(TokenId.from(0n)).toBe(0n)
|
|
6
|
+
expect(TokenId.from(0x1)).toBe(1n)
|
|
7
|
+
expect(TokenId.from(0xdef)).toBe(0xdefn)
|
|
8
|
+
expect(TokenId.from('0x20c0000000000000000000000000000000000000')).toBe(0n)
|
|
9
|
+
expect(TokenId.from('0x20c0000000000000000000000000000000000001')).toBe(1n)
|
|
10
|
+
expect(TokenId.from('0x20c0000000000000000000000000000000000def')).toBe(
|
|
11
|
+
0xdefn,
|
|
12
|
+
)
|
|
13
|
+
})
|
|
14
|
+
|
|
4
15
|
test('fromAddress', () => {
|
|
5
16
|
expect(
|
|
6
17
|
TokenId.fromAddress('0x20c0000000000000000000000000000000000000'),
|
package/src/ox/TokenId.ts
CHANGED
|
@@ -6,6 +6,21 @@ const tip20Prefix = '0x20c0'
|
|
|
6
6
|
export type TokenId = bigint
|
|
7
7
|
export type TokenIdOrAddress = TokenId | Address.Address
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Converts a token ID or address to a token ID.
|
|
11
|
+
*
|
|
12
|
+
* @param tokenIdOrAddress - The token ID or address.
|
|
13
|
+
* @returns The token ID.
|
|
14
|
+
*/
|
|
15
|
+
export function from(tokenIdOrAddress: TokenIdOrAddress | number): TokenId {
|
|
16
|
+
if (
|
|
17
|
+
typeof tokenIdOrAddress === 'bigint' ||
|
|
18
|
+
typeof tokenIdOrAddress === 'number'
|
|
19
|
+
)
|
|
20
|
+
return BigInt(tokenIdOrAddress)
|
|
21
|
+
return fromAddress(tokenIdOrAddress)
|
|
22
|
+
}
|
|
23
|
+
|
|
9
24
|
/**
|
|
10
25
|
* Converts a TIP20 token address to a token ID.
|
|
11
26
|
*
|
package/src/prool/Instance.ts
CHANGED
|
@@ -25,7 +25,7 @@ export const tempo = defineInstance((parameters: tempo.Parameters = {}) => {
|
|
|
25
25
|
...args
|
|
26
26
|
} = parameters
|
|
27
27
|
const { deadline = 3, gaslimit = 3000000000, maxTasks = 8 } = builder ?? {}
|
|
28
|
-
const { blockTime = '
|
|
28
|
+
const { blockTime = '1sec' } = dev ?? {}
|
|
29
29
|
const {
|
|
30
30
|
address = '0x20c0000000000000000000000000000000000001',
|
|
31
31
|
amount = 1000000000000000,
|
|
@@ -148,7 +148,7 @@ export declare namespace tempo {
|
|
|
148
148
|
/**
|
|
149
149
|
* Interval between blocks.
|
|
150
150
|
*/
|
|
151
|
-
blockTime?:
|
|
151
|
+
blockTime?: string | undefined
|
|
152
152
|
}
|
|
153
153
|
| undefined
|
|
154
154
|
/**
|
package/src/viem/Abis.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated with `
|
|
1
|
+
// Generated with `pnpm gen:abis`. Do not modify manually.
|
|
2
2
|
|
|
3
3
|
export const tip20 = [
|
|
4
4
|
{
|
|
@@ -1178,4 +1178,5 @@ export const stablecoinExchange = [
|
|
|
1178
1178
|
{ name: 'MaxInputExceeded', type: 'error', inputs: [] },
|
|
1179
1179
|
{ name: 'InsufficientOutput', type: 'error', inputs: [] },
|
|
1180
1180
|
{ name: 'PairDoesNotExist', type: 'error', inputs: [] },
|
|
1181
|
+
{ name: 'PairAlreadyExists', type: 'error', inputs: [] },
|
|
1181
1182
|
] as const
|
|
@@ -146,7 +146,7 @@ describe('buy', () => {
|
|
|
146
146
|
sender: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
|
|
147
147
|
|
|
148
148
|
Docs: https://viem.sh/docs/contract/writeContract
|
|
149
|
-
Version: viem@2.38.
|
|
149
|
+
Version: viem@2.38.3]
|
|
150
150
|
`)
|
|
151
151
|
})
|
|
152
152
|
|
|
@@ -175,7 +175,7 @@ describe('buy', () => {
|
|
|
175
175
|
sender: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
|
|
176
176
|
|
|
177
177
|
Docs: https://viem.sh/docs/contract/writeContract
|
|
178
|
-
Version: viem@2.38.
|
|
178
|
+
Version: viem@2.38.3]
|
|
179
179
|
`)
|
|
180
180
|
})
|
|
181
181
|
})
|
|
@@ -263,7 +263,7 @@ describe('cancel', () => {
|
|
|
263
263
|
sender: 0x8C8d35429F74ec245F8Ef2f4Fd1e551cFF97d650
|
|
264
264
|
|
|
265
265
|
Docs: https://viem.sh/docs/contract/writeContract
|
|
266
|
-
Version: viem@2.38.
|
|
266
|
+
Version: viem@2.38.3]
|
|
267
267
|
`)
|
|
268
268
|
})
|
|
269
269
|
|
|
@@ -287,7 +287,7 @@ describe('cancel', () => {
|
|
|
287
287
|
sender: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
|
|
288
288
|
|
|
289
289
|
Docs: https://viem.sh/docs/contract/writeContract
|
|
290
|
-
Version: viem@2.38.
|
|
290
|
+
Version: viem@2.38.3]
|
|
291
291
|
`)
|
|
292
292
|
})
|
|
293
293
|
})
|
|
@@ -440,7 +440,7 @@ describe('getBuyQuote', () => {
|
|
|
440
440
|
args: (0x20C0000000000000000000000000000000000004, 0x20c0000000000000000000000000000000000005, 100000000000000000000)
|
|
441
441
|
|
|
442
442
|
Docs: https://viem.sh/docs/contract/readContract
|
|
443
|
-
Version: viem@2.38.
|
|
443
|
+
Version: viem@2.38.3]
|
|
444
444
|
`)
|
|
445
445
|
})
|
|
446
446
|
})
|
|
@@ -516,7 +516,7 @@ describe('getOrder', () => {
|
|
|
516
516
|
args: (999)
|
|
517
517
|
|
|
518
518
|
Docs: https://viem.sh/docs/contract/readContract
|
|
519
|
-
Version: viem@2.38.
|
|
519
|
+
Version: viem@2.38.3]
|
|
520
520
|
`)
|
|
521
521
|
})
|
|
522
522
|
|
|
@@ -875,7 +875,7 @@ describe('getSellQuote', () => {
|
|
|
875
875
|
args: (0x20c0000000000000000000000000000000000005, 0x20C0000000000000000000000000000000000004, 100000000000000000000)
|
|
876
876
|
|
|
877
877
|
Docs: https://viem.sh/docs/contract/readContract
|
|
878
|
-
Version: viem@2.38.
|
|
878
|
+
Version: viem@2.38.3]
|
|
879
879
|
`)
|
|
880
880
|
})
|
|
881
881
|
})
|
|
@@ -985,7 +985,7 @@ describe('place', () => {
|
|
|
985
985
|
sender: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
|
|
986
986
|
|
|
987
987
|
Docs: https://viem.sh/docs/contract/writeContract
|
|
988
|
-
Version: viem@2.38.
|
|
988
|
+
Version: viem@2.38.3]
|
|
989
989
|
`)
|
|
990
990
|
|
|
991
991
|
// Test tick below min tick should fail
|
|
@@ -1009,7 +1009,7 @@ describe('place', () => {
|
|
|
1009
1009
|
sender: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
|
|
1010
1010
|
|
|
1011
1011
|
Docs: https://viem.sh/docs/contract/writeContract
|
|
1012
|
-
Version: viem@2.38.
|
|
1012
|
+
Version: viem@2.38.3]
|
|
1013
1013
|
`)
|
|
1014
1014
|
})
|
|
1015
1015
|
|
|
@@ -1144,7 +1144,7 @@ describe('placeFlip', () => {
|
|
|
1144
1144
|
sender: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
|
|
1145
1145
|
|
|
1146
1146
|
Docs: https://viem.sh/docs/contract/writeContract
|
|
1147
|
-
Version: viem@2.38.
|
|
1147
|
+
Version: viem@2.38.3]
|
|
1148
1148
|
`)
|
|
1149
1149
|
|
|
1150
1150
|
await expect(
|
|
@@ -1167,7 +1167,7 @@ describe('placeFlip', () => {
|
|
|
1167
1167
|
sender: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
|
|
1168
1168
|
|
|
1169
1169
|
Docs: https://viem.sh/docs/contract/writeContract
|
|
1170
|
-
Version: viem@2.38.
|
|
1170
|
+
Version: viem@2.38.3]
|
|
1171
1171
|
`)
|
|
1172
1172
|
})
|
|
1173
1173
|
|
|
@@ -1205,7 +1205,7 @@ describe('placeFlip', () => {
|
|
|
1205
1205
|
sender: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
|
|
1206
1206
|
|
|
1207
1207
|
Docs: https://viem.sh/docs/contract/writeContract
|
|
1208
|
-
Version: viem@2.38.
|
|
1208
|
+
Version: viem@2.38.3]
|
|
1209
1209
|
`)
|
|
1210
1210
|
|
|
1211
1211
|
await expect(
|
|
@@ -1228,7 +1228,7 @@ describe('placeFlip', () => {
|
|
|
1228
1228
|
sender: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
|
|
1229
1229
|
|
|
1230
1230
|
Docs: https://viem.sh/docs/contract/writeContract
|
|
1231
|
-
Version: viem@2.38.
|
|
1231
|
+
Version: viem@2.38.3]
|
|
1232
1232
|
`)
|
|
1233
1233
|
})
|
|
1234
1234
|
|
|
@@ -1302,7 +1302,7 @@ describe('sell', () => {
|
|
|
1302
1302
|
sender: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
|
|
1303
1303
|
|
|
1304
1304
|
Docs: https://viem.sh/docs/contract/writeContract
|
|
1305
|
-
Version: viem@2.38.
|
|
1305
|
+
Version: viem@2.38.3]
|
|
1306
1306
|
`)
|
|
1307
1307
|
})
|
|
1308
1308
|
|
|
@@ -1331,7 +1331,7 @@ describe('sell', () => {
|
|
|
1331
1331
|
sender: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
|
|
1332
1332
|
|
|
1333
1333
|
Docs: https://viem.sh/docs/contract/writeContract
|
|
1334
|
-
Version: viem@2.38.
|
|
1334
|
+
Version: viem@2.38.3]
|
|
1335
1335
|
`)
|
|
1336
1336
|
})
|
|
1337
1337
|
})
|
|
@@ -348,6 +348,40 @@ describe('getMetadata', () => {
|
|
|
348
348
|
`)
|
|
349
349
|
})
|
|
350
350
|
|
|
351
|
+
test('behavior: quote token', async () => {
|
|
352
|
+
{
|
|
353
|
+
const metadata = await actions.token.getMetadata(client, {
|
|
354
|
+
token: TokenIds.defaultQuoteToken,
|
|
355
|
+
})
|
|
356
|
+
|
|
357
|
+
expect(metadata).toMatchInlineSnapshot(`
|
|
358
|
+
{
|
|
359
|
+
"currency": "USD",
|
|
360
|
+
"decimals": 6,
|
|
361
|
+
"name": "linkingUSD",
|
|
362
|
+
"symbol": "linkingUSD",
|
|
363
|
+
"totalSupply": 0n,
|
|
364
|
+
}
|
|
365
|
+
`)
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
{
|
|
369
|
+
const metadata = await actions.token.getMetadata(client, {
|
|
370
|
+
token: Addresses.defaultQuoteToken,
|
|
371
|
+
})
|
|
372
|
+
|
|
373
|
+
expect(metadata).toMatchInlineSnapshot(`
|
|
374
|
+
{
|
|
375
|
+
"currency": "USD",
|
|
376
|
+
"decimals": 6,
|
|
377
|
+
"name": "linkingUSD",
|
|
378
|
+
"symbol": "linkingUSD",
|
|
379
|
+
"totalSupply": 0n,
|
|
380
|
+
}
|
|
381
|
+
`)
|
|
382
|
+
}
|
|
383
|
+
})
|
|
384
|
+
|
|
351
385
|
test('behavior: custom token (id)', async () => {
|
|
352
386
|
const token = await actions.token.createSync(client, {
|
|
353
387
|
currency: 'USD',
|
|
@@ -1452,6 +1452,47 @@ export async function getMetadata<chain extends Chain | undefined>(
|
|
|
1452
1452
|
const { token = Addresses.defaultFeeToken, ...rest } = parameters
|
|
1453
1453
|
const address = TokenId.toAddress(token)
|
|
1454
1454
|
const abi = Abis.tip20
|
|
1455
|
+
|
|
1456
|
+
if (TokenId.from(token) === TokenId.fromAddress(Addresses.defaultQuoteToken))
|
|
1457
|
+
return multicall(client, {
|
|
1458
|
+
...rest,
|
|
1459
|
+
contracts: [
|
|
1460
|
+
{
|
|
1461
|
+
address,
|
|
1462
|
+
abi,
|
|
1463
|
+
functionName: 'currency',
|
|
1464
|
+
},
|
|
1465
|
+
{
|
|
1466
|
+
address,
|
|
1467
|
+
abi,
|
|
1468
|
+
functionName: 'decimals',
|
|
1469
|
+
},
|
|
1470
|
+
{
|
|
1471
|
+
address,
|
|
1472
|
+
abi,
|
|
1473
|
+
functionName: 'name',
|
|
1474
|
+
},
|
|
1475
|
+
{
|
|
1476
|
+
address,
|
|
1477
|
+
abi,
|
|
1478
|
+
functionName: 'symbol',
|
|
1479
|
+
},
|
|
1480
|
+
{
|
|
1481
|
+
address,
|
|
1482
|
+
abi,
|
|
1483
|
+
functionName: 'totalSupply',
|
|
1484
|
+
},
|
|
1485
|
+
] as const,
|
|
1486
|
+
allowFailure: false,
|
|
1487
|
+
deployless: true,
|
|
1488
|
+
}).then(([currency, decimals, name, symbol, totalSupply]) => ({
|
|
1489
|
+
name,
|
|
1490
|
+
symbol,
|
|
1491
|
+
currency,
|
|
1492
|
+
decimals,
|
|
1493
|
+
totalSupply,
|
|
1494
|
+
}))
|
|
1495
|
+
|
|
1455
1496
|
return multicall(client, {
|
|
1456
1497
|
...rest,
|
|
1457
1498
|
contracts: [
|
|
@@ -1535,24 +1576,51 @@ export declare namespace getMetadata {
|
|
|
1535
1576
|
}
|
|
1536
1577
|
|
|
1537
1578
|
export type ReturnValue = Compute<{
|
|
1538
|
-
/**
|
|
1579
|
+
/**
|
|
1580
|
+
* Currency (e.g. "USD").
|
|
1581
|
+
*/
|
|
1539
1582
|
currency: string
|
|
1540
|
-
/**
|
|
1583
|
+
/**
|
|
1584
|
+
* Decimals of the token.
|
|
1585
|
+
*/
|
|
1541
1586
|
decimals: number
|
|
1542
|
-
/**
|
|
1543
|
-
|
|
1544
|
-
|
|
1587
|
+
/**
|
|
1588
|
+
* Quote token.
|
|
1589
|
+
*
|
|
1590
|
+
* Returns `undefined` for the default quote token (`0x20c...0000`).
|
|
1591
|
+
*/
|
|
1592
|
+
quoteToken?: Address | undefined
|
|
1593
|
+
/**
|
|
1594
|
+
* Name of the token.
|
|
1595
|
+
*/
|
|
1545
1596
|
name: string
|
|
1546
|
-
/**
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1597
|
+
/**
|
|
1598
|
+
* Whether the token is paused.
|
|
1599
|
+
*
|
|
1600
|
+
* Returns `undefined` for the default quote token (`0x20c...0000`).
|
|
1601
|
+
*/
|
|
1602
|
+
paused?: boolean | undefined
|
|
1603
|
+
/**
|
|
1604
|
+
* Supply cap.
|
|
1605
|
+
*
|
|
1606
|
+
* Returns `undefined` for the default quote token (`0x20c...0000`).
|
|
1607
|
+
*/
|
|
1608
|
+
supplyCap?: bigint | undefined
|
|
1609
|
+
/**
|
|
1610
|
+
* Symbol of the token.
|
|
1611
|
+
*/
|
|
1551
1612
|
symbol: string
|
|
1552
|
-
/**
|
|
1613
|
+
/**
|
|
1614
|
+
* Total supply of the token.
|
|
1615
|
+
*/
|
|
1553
1616
|
totalSupply: bigint
|
|
1554
|
-
/**
|
|
1555
|
-
|
|
1617
|
+
/**
|
|
1618
|
+
* Transfer policy ID.
|
|
1619
|
+
* 0="always-reject", 1="always-allow", >2=custom policy
|
|
1620
|
+
*
|
|
1621
|
+
* Returns `undefined` for the default quote token (`0x20c...0000`).
|
|
1622
|
+
*/
|
|
1623
|
+
transferPolicyId?: bigint | undefined
|
|
1556
1624
|
}>
|
|
1557
1625
|
}
|
|
1558
1626
|
|
|
@@ -1910,7 +1978,6 @@ export namespace mint {
|
|
|
1910
1978
|
const call = mint.call(parameters)
|
|
1911
1979
|
return (await action(client, {
|
|
1912
1980
|
...parameters,
|
|
1913
|
-
gas: 30_000n,
|
|
1914
1981
|
...call,
|
|
1915
1982
|
} as never)) as never
|
|
1916
1983
|
}
|
package/src/viem/e2e.test.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import * as Http from 'node:http'
|
|
2
|
+
import { createRequestListener } from '@remix-run/node-fetch-server'
|
|
3
3
|
import { RpcRequest, RpcResponse } from 'ox'
|
|
4
4
|
import { Transaction } from 'tempo.ts/viem'
|
|
5
5
|
import { createClient, http, publicActions, walletActions } from 'viem'
|
|
@@ -330,11 +330,11 @@ describe('signTransaction', () => {
|
|
|
330
330
|
})
|
|
331
331
|
|
|
332
332
|
describe('relay', () => {
|
|
333
|
-
let server:
|
|
333
|
+
let server: Http.Server
|
|
334
334
|
|
|
335
335
|
beforeAll(async () => {
|
|
336
|
-
server =
|
|
337
|
-
|
|
336
|
+
server = Http.createServer(
|
|
337
|
+
createRequestListener(async (r) => {
|
|
338
338
|
const client = createClient({
|
|
339
339
|
account: mnemonicToAccount(
|
|
340
340
|
'test test test test test test test test test test test junk',
|
|
@@ -343,7 +343,7 @@ describe('relay', () => {
|
|
|
343
343
|
transport: http(),
|
|
344
344
|
}).extend(walletActions)
|
|
345
345
|
|
|
346
|
-
const request = RpcRequest.from(
|
|
346
|
+
const request = RpcRequest.from(await r.json())
|
|
347
347
|
|
|
348
348
|
if (
|
|
349
349
|
request.method !== 'eth_sendRawTransaction' &&
|
|
@@ -385,17 +385,18 @@ describe('relay', () => {
|
|
|
385
385
|
})
|
|
386
386
|
|
|
387
387
|
return Response.json(RpcResponse.from({ result }, { request }))
|
|
388
|
-
})
|
|
389
|
-
|
|
388
|
+
}),
|
|
389
|
+
).listen(3000)
|
|
390
390
|
})
|
|
391
391
|
|
|
392
392
|
afterAll(() => {
|
|
393
|
+
server.close()
|
|
393
394
|
process.on('SIGINT', () => {
|
|
394
|
-
server.
|
|
395
|
+
server.close()
|
|
395
396
|
process.exit(0)
|
|
396
397
|
})
|
|
397
398
|
process.on('SIGTERM', () => {
|
|
398
|
-
server.
|
|
399
|
+
server.close()
|
|
399
400
|
process.exit(0)
|
|
400
401
|
})
|
|
401
402
|
})
|