Skip to content

Commit ff0516c

Browse files
committed
Merge branch 'main' into add-positionsCreate
2 parents 1eea6fa + 58aeef0 commit ff0516c

13 files changed

Lines changed: 1573 additions & 924 deletions

lib/addresses.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,28 @@ export const addresses = {
3333
withdraw: '0xFBfB9aD095f906d7E354F7ee31d88F0ca517A9C0',
3434
},
3535
},
36+
polygon: {
37+
mainnet: {
38+
token: '0xA5577D1cec2583058A6Bd6d5DEAC44797c205701',
39+
lockup: '0x42767B12d3f07bE0D951a64eE6573B40Ff165C4e',
40+
marketFactory: '0xEA518Ab9551d3cD9Ec4C74df1fa6946B18212178',
41+
metricsFactory: '0xD18f2eB75cE3a6A35586115b2f2c63d907536CDE',
42+
policyFactory: '0xD42c04179410a38BE95737e663480a7CC42B9C05',
43+
propertyFactory: '0x8bB6a34afBD34663cEeEFA697918c647Da22a352',
44+
registry: '0xbeF4DeEA3AE863739Bd402E025c749536f491ffa',
45+
sTokens: '0x89904De861CDEd2567695271A511B3556659FfA2',
46+
withdraw: '0x60d1743fc6791aEDB833E4aED604eccb9EC838DE',
47+
},
48+
mumbai: {
49+
token: '0xcbc698ed514dF6e54932a22515d6D0C27E4DA091',
50+
lockup: '0xfDC5FF1F07871A247eafE14eEB134eeFcbCf1ceA',
51+
marketFactory: '0x953992D325d8A9Bab35406C2E34c0d5535fa5206',
52+
metricsFactory: '0x02d107567020bCE1Eb524D80C44f899Fa9993E5f',
53+
policyFactory: '0x0f85eC41980E86847Ba57eA763E9c5f88f829554',
54+
propertyFactory: '0xcCB7e1454d66fc3c2053694D323c127D2a4b39BA',
55+
registry: '0xe2C16936413D74c667aeF0D040c920BF639067d4',
56+
sTokens: '0xe0af15141ABd0B31Fb15e250971936Fe8837230a',
57+
withdraw: '0x5f9d9f40f4d7d8A350745D69e94E20339Df17b83',
58+
},
59+
},
3660
} as const

lib/ethereum/s-tokens/abi.ts

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,44 @@ export const sTokensAbi = [
4949
name: 'ApprovalForAll',
5050
type: 'event',
5151
},
52+
{
53+
anonymous: false,
54+
inputs: [
55+
{
56+
indexed: false,
57+
internalType: 'uint256',
58+
name: 'tokenId',
59+
type: 'uint256',
60+
},
61+
{
62+
indexed: false,
63+
internalType: 'address',
64+
name: 'freezingUser',
65+
type: 'address',
66+
},
67+
],
68+
name: 'Freezed',
69+
type: 'event',
70+
},
71+
{
72+
anonymous: false,
73+
inputs: [
74+
{
75+
indexed: false,
76+
internalType: 'uint256',
77+
name: 'tokenId',
78+
type: 'uint256',
79+
},
80+
{
81+
indexed: false,
82+
internalType: 'address',
83+
name: 'meltingUser',
84+
type: 'address',
85+
},
86+
],
87+
name: 'Melted',
88+
type: 'event',
89+
},
5290
{
5391
anonymous: false,
5492
inputs: [
@@ -86,6 +124,31 @@ export const sTokensAbi = [
86124
name: 'Minted',
87125
type: 'event',
88126
},
127+
{
128+
anonymous: false,
129+
inputs: [
130+
{
131+
indexed: false,
132+
internalType: 'uint256',
133+
name: 'tokenId',
134+
type: 'uint256',
135+
},
136+
{
137+
indexed: false,
138+
internalType: 'address',
139+
name: 'author',
140+
type: 'address',
141+
},
142+
{
143+
indexed: false,
144+
internalType: 'string',
145+
name: 'data',
146+
type: 'string',
147+
},
148+
],
149+
name: 'SetTokenUri',
150+
type: 'event',
151+
},
89152
{
90153
anonymous: false,
91154
inputs: [
@@ -198,6 +261,61 @@ export const sTokensAbi = [
198261
stateMutability: 'view',
199262
type: 'function',
200263
},
264+
{
265+
inputs: [],
266+
name: 'descriptorAddress',
267+
outputs: [
268+
{
269+
internalType: 'address',
270+
name: '',
271+
type: 'address',
272+
},
273+
],
274+
stateMutability: 'view',
275+
type: 'function',
276+
},
277+
{
278+
inputs: [
279+
{
280+
internalType: 'uint256',
281+
name: '_tokenId',
282+
type: 'uint256',
283+
},
284+
],
285+
name: 'descriptors',
286+
outputs: [
287+
{
288+
internalType: 'bool',
289+
name: '',
290+
type: 'bool',
291+
},
292+
{
293+
internalType: 'address',
294+
name: '',
295+
type: 'address',
296+
},
297+
{
298+
internalType: 'string',
299+
name: '',
300+
type: 'string',
301+
},
302+
],
303+
stateMutability: 'view',
304+
type: 'function',
305+
},
306+
{
307+
inputs: [
308+
{
309+
internalType: 'uint256',
310+
name: '_tokenId',
311+
type: 'uint256',
312+
},
313+
],
314+
name: 'freezeTokenURI',
315+
outputs: [],
316+
stateMutability: 'nonpayable',
317+
type: 'function',
318+
},
201319
{
202320
inputs: [
203321
{
@@ -254,6 +372,19 @@ export const sTokensAbi = [
254372
stateMutability: 'view',
255373
type: 'function',
256374
},
375+
{
376+
inputs: [
377+
{
378+
internalType: 'uint256',
379+
name: '_tokenId',
380+
type: 'uint256',
381+
},
382+
],
383+
name: 'meltTokenURI',
384+
outputs: [],
385+
stateMutability: 'nonpayable',
386+
type: 'function',
387+
},
257388
{
258389
inputs: [
259390
{
@@ -495,6 +626,37 @@ export const sTokensAbi = [
495626
stateMutability: 'nonpayable',
496627
type: 'function',
497628
},
629+
{
630+
inputs: [
631+
{
632+
internalType: 'address',
633+
name: '_descriptor',
634+
type: 'address',
635+
},
636+
],
637+
name: 'setDescriptor',
638+
outputs: [],
639+
stateMutability: 'nonpayable',
640+
type: 'function',
641+
},
642+
{
643+
inputs: [
644+
{
645+
internalType: 'uint256',
646+
name: '_tokenId',
647+
type: 'uint256',
648+
},
649+
{
650+
internalType: 'string',
651+
name: '_data',
652+
type: 'string',
653+
},
654+
],
655+
name: 'setTokenURIImage',
656+
outputs: [],
657+
stateMutability: 'nonpayable',
658+
type: 'function',
659+
},
498660
{
499661
inputs: [
500662
{
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { createFreezeTokenURICaller } from './freezeTokenURI'
2+
import { stubbedSendTx } from '../../common/utils/for-test'
3+
4+
describe('freezeTokenURI.spec.ts', () => {
5+
describe('createFreezeTokenURICaller', () => {
6+
it('call success', async () => {
7+
const success = true
8+
const tokenId = 1
9+
10+
const devContract = {
11+
freezeTokenURI: jest
12+
.fn()
13+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
14+
.mockImplementation(async (tokenId: string) => stubbedSendTx()),
15+
}
16+
17+
const expected = success
18+
19+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
20+
const caller = createFreezeTokenURICaller(devContract as any)
21+
22+
const result = await caller(tokenId)
23+
24+
expect(result).toEqual(expected)
25+
})
26+
27+
it('call failure', async () => {
28+
const tokenId = 1
29+
const error = 'error'
30+
31+
const devContract = {
32+
freezeTokenURI: jest
33+
.fn()
34+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
35+
.mockImplementation(async (tokenId: string) => Promise.reject(error)),
36+
}
37+
38+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
39+
const caller = createFreezeTokenURICaller(devContract as any)
40+
41+
const result = await caller(tokenId).catch((err) => err)
42+
43+
expect(result).toEqual(error)
44+
})
45+
})
46+
})
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { ethers } from 'ethers'
2+
import {
3+
execute,
4+
FallbackableOverrides,
5+
MutationOption,
6+
} from '../../common/utils/execute'
7+
import { T } from 'ramda'
8+
9+
export type CreateFreezeTokenURICaller = (
10+
contract: ethers.Contract
11+
) => (tokenId: number, overrides?: FallbackableOverrides) => Promise<boolean>
12+
13+
export const createFreezeTokenURICaller: CreateFreezeTokenURICaller =
14+
(contract: ethers.Contract) =>
15+
async (tokenId: number, overrides?: FallbackableOverrides) =>
16+
execute<MutationOption>({
17+
contract,
18+
method: 'freezeTokenURI',
19+
mutation: true,
20+
args: [String(tokenId)],
21+
overrides,
22+
}).then(T)

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,14 @@ import { createRewardsCaller } from './rewards'
77
import { createTokenURICaller } from './tokenURI'
88
import { createPositionsOfPropertyCaller } from './positionsOfProperty'
99
import { createPositionsOfOwnerCaller } from './positionsOfOwner'
10+
import { createIsFreezedCaller } from './isFreezed'
11+
import { createFreezeTokenURICaller } from './freezeTokenURI'
12+
import { createSetTokenURIImageCaller } from './setTokenURIImage'
1013

1114
jest.mock('./positions')
15+
jest.mock('./isFreezed')
16+
jest.mock('./freezeTokenURI')
17+
jest.mock('./setTokenURIImage')
1218
jest.mock('./ownerOf')
1319
jest.mock('./rewards')
1420
jest.mock('./tokenURI')
@@ -19,6 +25,7 @@ describe('s-tokens/index.ts', () => {
1925
;(createPositionsCaller as jest.Mock).mockImplementation(
2026
(contract) => contract
2127
)
28+
;(createOwnerOfCaller as jest.Mock).mockImplementation((contract) => contract)
2229
;(createRewardsCaller as jest.Mock).mockImplementation((contract) => contract)
2330
;(createTokenURICaller as jest.Mock).mockImplementation(
2431
(contract) => contract
@@ -29,6 +36,15 @@ describe('s-tokens/index.ts', () => {
2936
;(createPositionsOfOwnerCaller as jest.Mock).mockImplementation(
3037
(contract) => contract
3138
)
39+
;(createIsFreezedCaller as jest.Mock).mockImplementation(
40+
(contract) => contract
41+
)
42+
;(createFreezeTokenURICaller as jest.Mock).mockImplementation(
43+
(contract) => contract
44+
)
45+
;(createSetTokenURIImageCaller as jest.Mock).mockImplementation(
46+
(contract) => contract
47+
)
3248
describe('createSTokensContract', () => {
3349
it('check return object', () => {
3450
const host = 'localhost'
@@ -41,6 +57,9 @@ describe('s-tokens/index.ts', () => {
4157
const contract = new ethers.Contract(address, [...sTokensAbi], provider)
4258
return {
4359
positions: createPositionsCaller(contract),
60+
isFreezed: createIsFreezedCaller(contract),
61+
freezeTokenURI: createFreezeTokenURICaller(contract),
62+
setTokenURIImage: createSetTokenURIImageCaller(contract),
4463
ownerOf: createOwnerOfCaller(contract),
4564
rewards: createRewardsCaller(contract),
4665
tokenURI: createTokenURICaller(contract),

lib/ethereum/s-tokens/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import { Provider } from '@ethersproject/abstract-provider'
33
import { Signer } from '@ethersproject/abstract-signer'
44
import { sTokensAbi } from './abi'
55
import { createPositionsCaller, Positions } from './positions'
6+
import { createIsFreezedCaller } from './isFreezed'
7+
import { createFreezeTokenURICaller } from './freezeTokenURI'
8+
import { createSetTokenURIImageCaller } from './setTokenURIImage'
69
import { createOwnerOfCaller } from './ownerOf'
710
import { createRewardsCaller, Rewards } from './rewards'
811
import { createTokenURICaller, TokenURI } from './tokenURI'
@@ -11,6 +14,9 @@ import { createPositionsOfOwnerCaller } from './positionsOfOwner'
1114

1215
export type STokensContract = {
1316
readonly positions: (tokenId: number) => Promise<Positions>
17+
readonly isFreezed: (tokenId: number) => Promise<boolean>
18+
readonly freezeTokenURI: (tokenId: number) => Promise<boolean>
19+
readonly setTokenURIImage: (tokenId: number, data: string) => Promise<boolean>
1420
readonly ownerOf: (tokenId: number) => Promise<string>
1521
readonly rewards: (tokenId: number) => Promise<Rewards>
1622
readonly tokenURI: (tokenId: number) => Promise<TokenURI>
@@ -34,6 +40,9 @@ export const createSTokensContract =
3440

3541
return {
3642
positions: createPositionsCaller(contractClient),
43+
isFreezed: createIsFreezedCaller(contractClient),
44+
freezeTokenURI: createFreezeTokenURICaller(contractClient),
45+
setTokenURIImage: createSetTokenURIImageCaller(contractClient),
3746
ownerOf: createOwnerOfCaller(contractClient),
3847
rewards: createRewardsCaller(contractClient),
3948
tokenURI: createTokenURICaller(contractClient),

0 commit comments

Comments
 (0)