Skip to content

Commit 54d28d5

Browse files
committed
Merge remote-tracking branch 'origin/main' into ethers-v6
2 parents a3f2638 + 59bcd2a commit 54d28d5

25 files changed

+2944
-1106
lines changed

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ jobs:
2525
run: |
2626
yarn install
2727
yarn run build
28-
- uses: JS-DevTools/npm-publish@v1
28+
- uses: JS-DevTools/npm-publish@v2
2929
with:
3030
token: ${{ secrets.NPM_TOKEN }}

lib/agent/common/agentAddresses.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ export const agentAddresses = {
2929
mumbai: {
3030
swap: {
3131
v2: undefined,
32-
v3: '0x01C818717B5471562172f3F886E4C4dC053D6ed8',
32+
v3: '0x60650E5a95864b989C8b7B0357a2d4979a34c6AF',
3333
},
34-
weth: '0xA6FA4fB5f76172d178d61B04b0ecd319C5d1C0aa',
34+
weth: '0x3c8d6A6420C922c88577352983aFFdf7b0F977cA',
3535
},
3636
},
3737
} as const

lib/agent/positionsCreateWithEth.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ export const positionsCreateWithEth: PositionsCreateWithEth = async (
5151
((await options.provider.provider?.getBlock('latest'))?.timestamp ??
5252
Math.floor(new Date().getTime() / 1000)) + 300
5353

54-
return options.gatewayAddress && options.gatewayBasisPoints
54+
return options.gatewayAddress &&
55+
typeof options.gatewayBasisPoints === 'number'
5556
? await l2.swapEthAndStakeDevCaller(
5657
options.destination,
5758
deadline,

lib/agent/positionsCreateWithEthForPolygon.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,9 @@ export const positionsCreateWithEth: PositionsCreateWithEthForPolygon = async (
6060
callback: async () => {
6161
const deadline = options.deadline
6262
? options.deadline
63-
: ((await options.provider.provider?.getBlock('latest'))
64-
?.timestamp ?? Math.floor(new Date().getTime() / 1000)) +
65-
300
66-
return options.gatewayAddress && options.gatewayBasisPoints
63+
: (await options.provider.getBlock('latest')).timestamp + 300
64+
return options.gatewayAddress &&
65+
typeof options.gatewayBasisPoints === 'number'
6766
? l2.swapEthAndStakeDevPolygonCaller(
6867
options.destination,
6968
ethAmount,

lib/common/utils/execute.ts

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,22 @@ import {
77
import { TransactionResponse } from '@ethersproject/abstract-provider'
88
import { keys, mergeAll } from 'ramda'
99

10-
type Args = ReadonlyArray<string | boolean | readonly string[] | Uint8Array>
11-
type ArgsWithoutUint8Array = ReadonlyArray<string | boolean | readonly string[]>
10+
import { Positions } from '../../ethereum/s-tokens'
11+
import { Rewards } from '../../ethereum/s-tokens/rewards'
12+
import { Image } from '../../ethereum/simpleCollection/types'
13+
14+
type Args = ReadonlyArray<
15+
| string
16+
| boolean
17+
| readonly string[]
18+
| Uint8Array
19+
| readonly Image[]
20+
| Positions
21+
| Rewards
22+
>
23+
type ArgsWithoutUint8Array = ReadonlyArray<
24+
string | boolean | readonly string[] | readonly Image[] | Positions | Rewards
25+
>
1226
type Overrides = {
1327
readonly gasLimit?: number
1428
readonly from?: string
@@ -53,7 +67,14 @@ export type ExecuteFunction = <
5367
>
5468
type PadCaller = (
5569
arr: ArgsWithoutUint8Array,
56-
v: string | boolean | undefined | readonly string[],
70+
v:
71+
| string
72+
| boolean
73+
| undefined
74+
| readonly string[]
75+
| readonly Image[]
76+
| Positions
77+
| Rewards,
5778
i: number,
5879
fn: PadCaller
5980
) => ArgsWithoutUint8Array
@@ -64,7 +85,14 @@ const pad = (
6485
((fn: PadCaller): ArgsWithoutUint8Array => fn([], args[0], 0, fn))(
6586
(
6687
arr: ArgsWithoutUint8Array,
67-
v: string | boolean | undefined | readonly string[],
88+
v:
89+
| string
90+
| boolean
91+
| undefined
92+
| readonly string[]
93+
| readonly Image[]
94+
| Positions
95+
| Rewards,
6896
i: number,
6997
fn: PadCaller
7098
): ArgsWithoutUint8Array =>

lib/ethereum/contract.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { createMetricsContract } from './metrics'
1919
import { createPolicyFactoryContract } from './policy-factory'
2020
import { createSTokensContract } from './s-tokens'
2121
import { createMetricsGroupContract } from './metrics-group'
22+
import { createSimpleCollectionsContract } from './simpleCollection'
2223

2324
describe('contract.ts', () => {
2425
describe('createDevkitContract', () => {
@@ -42,6 +43,7 @@ describe('contract.ts', () => {
4243
metricsGroup: createMetricsGroupContract(provider),
4344
policyFactory: createPolicyFactoryContract(provider),
4445
sTokens: createSTokensContract(provider),
46+
simpleCollections: createSimpleCollectionsContract(provider)
4547
}
4648

4749
const result = createDevkitContract(provider)

lib/ethereum/contract.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { createMetricsContract } from './metrics'
1515
import { createPolicyFactoryContract } from './policy-factory'
1616
import { createSTokensContract } from './s-tokens'
1717
import { createMetricsGroupContract } from './metrics-group'
18+
import { createSimpleCollectionsContract } from './simpleCollection'
1819
import { ContractRunner } from 'ethers'
1920

2021
export type DevkitContract = {
@@ -33,6 +34,7 @@ export type DevkitContract = {
3334
readonly metricsGroup: ReturnType<typeof createMetricsGroupContract>
3435
readonly policyFactory: ReturnType<typeof createPolicyFactoryContract>
3536
readonly sTokens: ReturnType<typeof createSTokensContract>
37+
readonly simpleCollections: ReturnType<typeof createSimpleCollectionsContract>
3638
}
3739
export type ContractFactory = (ethersProvider: ContractRunner) => DevkitContract
3840
export type CreateDevkitContract = (provider: ContractRunner) => DevkitContract
@@ -55,6 +57,7 @@ export const createDevkitContract: CreateDevkitContract = (
5557
metricsGroup: createMetricsGroupContract(provider),
5658
policyFactory: createPolicyFactoryContract(provider),
5759
sTokens: createSTokensContract(provider),
60+
simpleCollections: createSimpleCollectionsContract(provider),
5861
})
5962

6063
export const contractFactory: ContractFactory = createDevkitContract

lib/ethereum/s-tokens/tokenURI.spec.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,21 @@ describe('tokenURI.spec.ts', () => {
55
it('call success', async () => {
66
const data = {
77
name: 'NAME',
8-
description: 'DESCRIPTION',
8+
description: 'DESCRIPTION_1\n\nDESCRIPTION_2',
99
image: 'data:image/svg+xml;base64,<svg></svg>',
10+
attributes: [
11+
{
12+
trait_type: 'Destination',
13+
value: '0x0',
14+
},
15+
{
16+
trait_type: 'Locked Amount',
17+
display_type: 'number',
18+
value: 123.456,
19+
},
20+
],
1021
}
11-
const value = `data:application/json;base64,eyJuYW1lIjoiTkFNRSIsICJkZXNjcmlwdGlvbiI6IkRFU0NSSVBUSU9OIiwgImltYWdlIjogImRhdGE6aW1hZ2Uvc3ZnK3htbDtiYXNlNjQsPHN2Zz48L3N2Zz4ifQ==`
22+
const value = `data:application/json;base64,eyJuYW1lIjoiTkFNRSIsImRlc2NyaXB0aW9uIjoiREVTQ1JJUFRJT05fMVxuXG5ERVNDUklQVElPTl8yIiwiaW1hZ2UiOiJkYXRhOmltYWdlL3N2Zyt4bWw7YmFzZTY0LDxzdmc+PC9zdmc+IiwiYXR0cmlidXRlcyI6W3sidHJhaXRfdHlwZSI6IkRlc3RpbmF0aW9uIiwidmFsdWUiOiIweDAifSx7InRyYWl0X3R5cGUiOiJMb2NrZWQgQW1vdW50IiwiZGlzcGxheV90eXBlIjoibnVtYmVyIiwidmFsdWUiOjEyMy40NTZ9XX0=`
1223

1324
const contract = {
1425
tokenURI: jest

lib/ethereum/s-tokens/tokenURI.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ export type TokenURI = {
77
readonly name: string
88
readonly description: string
99
readonly image: string
10+
readonly attributes: readonly [
11+
{
12+
readonly trait_type: 'Destination'
13+
readonly value: string
14+
},
15+
{
16+
readonly trait_type: 'Locked Amount'
17+
readonly display_type: 'number'
18+
readonly value: number
19+
}
20+
]
1021
}
1122

1223
export type CreateTokenURICaller = (
@@ -23,6 +34,6 @@ export const createTokenURICaller: CreateTokenURICaller =
2334
})
2435
const decoded = decode(
2536
res.replace(/^data:application\/json;base64,(.*)/, '$1')
26-
)
37+
).replace(/\n/g, '\\n')
2738
return JSON.parse(decoded)
2839
}

lib/ethereum/s-tokens/tokenURISim.spec.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,21 @@ describe('tokenURISim.spec.ts', () => {
66
it('call success', async () => {
77
const data = {
88
name: 'NAME',
9-
description: 'DESCRIPTION',
9+
description: 'DESCRIPTION_1\n\nDESCRIPTION_2',
1010
image: 'data:image/svg+xml;base64,<svg></svg>',
11+
attributes: [
12+
{
13+
trait_type: 'Destination',
14+
value: '0x0',
15+
},
16+
{
17+
trait_type: 'Locked Amount',
18+
display_type: 'number',
19+
value: 123.456,
20+
},
21+
],
1122
}
12-
const value = `data:application/json;base64,eyJuYW1lIjoiTkFNRSIsICJkZXNjcmlwdGlvbiI6IkRFU0NSSVBUSU9OIiwgImltYWdlIjogImRhdGE6aW1hZ2Uvc3ZnK3htbDtiYXNlNjQsPHN2Zz48L3N2Zz4ifQ==`
23+
const value = `data:application/json;base64,eyJuYW1lIjoiTkFNRSIsImRlc2NyaXB0aW9uIjoiREVTQ1JJUFRJT05fMVxuXG5ERVNDUklQVElPTl8yIiwiaW1hZ2UiOiJkYXRhOmltYWdlL3N2Zyt4bWw7YmFzZTY0LDxzdmc+PC9zdmc+IiwiYXR0cmlidXRlcyI6W3sidHJhaXRfdHlwZSI6IkRlc3RpbmF0aW9uIiwidmFsdWUiOiIweDAifSx7InRyYWl0X3R5cGUiOiJMb2NrZWQgQW1vdW50IiwiZGlzcGxheV90eXBlIjoibnVtYmVyIiwidmFsdWUiOjEyMy40NTZ9XX0=`
1324

1425
const contract = {
1526
tokenURISim: jest

0 commit comments

Comments
 (0)