git.delta.rocks / unique-network / refs/commits / 46515fa1c836

difftreelog

Merge pull request #826 from UniqueNetwork/fix/deprecate-eth-methods

ut-akuznetsov2023-01-12parents: #6994f61 #766b8da.patch.diff
in: master
Deprecate ethereum methods

9 files changed

modifiedtests/src/eth/abi/fungibleDeprecated.jsondiffbeforeafterboth
88 "outputs": [],88 "outputs": [],
89 "stateMutability": "nonpayable",89 "stateMutability": "nonpayable",
90 "type": "function"90 "type": "function"
91 },91 }
92 {
93 "inputs": [
94 { "internalType": "address", "name": "newOwner", "type": "address" }
95 ],
96 "name": "changeCollectionOwner",
97 "outputs": [],
98 "stateMutability": "nonpayable",
99 "type": "function"
100 }
101]92]
10293
modifiedtests/src/eth/abi/nonFungible.jsondiffbeforeafterboth
49 "name": "ApprovalForAll",49 "name": "ApprovalForAll",
50 "type": "event"50 "type": "event"
51 },51 },
52 {
53 "anonymous": false,
54 "inputs": [],
55 "name": "MintingFinished",
56 "type": "event"
57 },
58 {52 {
59 "anonymous": false,53 "anonymous": false,
60 "inputs": [54 "inputs": [
422 "stateMutability": "view",416 "stateMutability": "view",
423 "type": "function"417 "type": "function"
424 },418 },
425 {
426 "inputs": [],
427 "name": "finishMinting",
428 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
429 "stateMutability": "nonpayable",
430 "type": "function"
431 },
432 {419 {
433 "inputs": [420 "inputs": [
434 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }421 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }
515 "stateMutability": "nonpayable",502 "stateMutability": "nonpayable",
516 "type": "function"503 "type": "function"
517 },504 },
518 {
519 "inputs": [],
520 "name": "mintingFinished",
521 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
522 "stateMutability": "view",
523 "type": "function"
524 },
525 {505 {
526 "inputs": [],506 "inputs": [],
527 "name": "name",507 "name": "name",
modifiedtests/src/eth/abi/reFungible.jsondiffbeforeafterboth
49 "name": "ApprovalForAll",49 "name": "ApprovalForAll",
50 "type": "event"50 "type": "event"
51 },51 },
52 {
53 "anonymous": false,
54 "inputs": [],
55 "name": "MintingFinished",
56 "type": "event"
57 },
58 {52 {
59 "anonymous": false,53 "anonymous": false,
60 "inputs": [54 "inputs": [
404 "stateMutability": "view",398 "stateMutability": "view",
405 "type": "function"399 "type": "function"
406 },400 },
407 {
408 "inputs": [],
409 "name": "finishMinting",
410 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
411 "stateMutability": "nonpayable",
412 "type": "function"
413 },
414 {401 {
415 "inputs": [402 "inputs": [
416 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }403 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }
497 "stateMutability": "nonpayable",484 "stateMutability": "nonpayable",
498 "type": "function"485 "type": "function"
499 },486 },
500 {
501 "inputs": [],
502 "name": "mintingFinished",
503 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
504 "stateMutability": "view",
505 "type": "function"
506 },
507 {487 {
508 "inputs": [],488 "inputs": [],
509 "name": "name",489 "name": "name",
modifiedtests/src/eth/abi/reFungibleDeprecated.jsondiffbeforeafterboth
80 "stateMutability": "nonpayable",80 "stateMutability": "nonpayable",
81 "type": "function"81 "type": "function"
82 },82 },
83 {
84 "inputs": [
85 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },
86 { "internalType": "string", "name": "key", "type": "string" },
87 { "internalType": "bytes", "name": "value", "type": "bytes" }
88 ],
89 "name": "setProperty",
90 "outputs": [],
91 "stateMutability": "nonpayable",
92 "type": "function"
93 },
83 {94 {
84 "inputs": [95 "inputs": [
85 { "internalType": "address", "name": "newOwner", "type": "address" }96 { "internalType": "address", "name": "newOwner", "type": "address" }
modifiedtests/src/eth/abi/reFungibleToken.jsondiffbeforeafterboth
96 "stateMutability": "view",96 "stateMutability": "view",
97 "type": "function"97 "type": "function"
98 },98 },
99 {
100 "inputs": [
101 { "internalType": "address", "name": "from", "type": "address" },
102 { "internalType": "uint256", "name": "amount", "type": "uint256" }
103 ],
104 "name": "burnFrom",
105 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
106 "stateMutability": "nonpayable",
107 "type": "function"
108 },
109 {99 {
110 "inputs": [100 "inputs": [
111 {101 {
addedtests/src/eth/abi/reFungibleTokenDeprecated.jsondiffbeforeafterboth

no changes

modifiedtests/src/eth/reFungible.test.tsdiffbeforeafterboth
7474
75 const result = await contract.methods.mint(caller).send();75 const result = await contract.methods.mint(caller).send();
76 const tokenId = result.events.Transfer.returnValues.tokenId;76 const tokenId = result.events.Transfer.returnValues.tokenId;
77 const tokenContract = await helper.ethNativeContract.rftTokenById(collectionId, tokenId, caller);77 const tokenContract = await helper.ethNativeContract.rftTokenById(collectionId, tokenId, caller, true);
7878
79 await tokenContract.methods.repartition(2).send();79 await tokenContract.methods.repartition(2).send();
80 await tokenContract.methods.transfer(receiver, 1).send();80 await tokenContract.methods.transfer(receiver, 1).send();
316 const address = helper.ethAddress.fromCollectionId(collection.collectionId);316 const address = helper.ethAddress.fromCollectionId(collection.collectionId);
317 const contract = await helper.ethNativeContract.collection(address, 'rft');317 const contract = await helper.ethNativeContract.collection(address, 'rft');
318318
319 const rftToken = await helper.ethNativeContract.rftTokenById(token.collectionId, token.tokenId, owner);319 const rftToken = await helper.ethNativeContract.rftTokenById(token.collectionId, token.tokenId, owner, true);
320320
321 {321 {
322 await rftToken.methods.approve(operator, 15n).send({from: owner});322 await rftToken.methods.approve(operator, 15n).send({from: owner});
modifiedtests/src/eth/reFungibleToken.test.tsdiffbeforeafterboth
458 const result = await contract.methods.mint(caller).send();458 const result = await contract.methods.mint(caller).send();
459 const tokenId = result.events.Transfer.returnValues.tokenId;459 const tokenId = result.events.Transfer.returnValues.tokenId;
460 const tokenAddress = helper.ethAddress.fromTokenId(collectionId, tokenId);460 const tokenAddress = helper.ethAddress.fromTokenId(collectionId, tokenId);
461 const tokenContract = await helper.ethNativeContract.rftToken(tokenAddress, caller);461 const tokenContract = await helper.ethNativeContract.rftToken(tokenAddress, caller, true);
462462
463 await tokenContract.methods.repartition(2).send();463 await tokenContract.methods.repartition(2).send();
464 await tokenContract.methods.transfer(receiver, 1).send();464 await tokenContract.methods.transfer(receiver, 1).send();
modifiedtests/src/eth/util/playgrounds/unique.dev.tsdiffbeforeafterboth
29import refungibleAbi from '../../abi/reFungible.json';29import refungibleAbi from '../../abi/reFungible.json';
30import refungibleDeprecatedAbi from '../../abi/reFungibleDeprecated.json';30import refungibleDeprecatedAbi from '../../abi/reFungibleDeprecated.json';
31import refungibleTokenAbi from '../../abi/reFungibleToken.json';31import refungibleTokenAbi from '../../abi/reFungibleToken.json';
32import refungibleTokenDeprecatedAbi from '../../abi/reFungibleTokenDeprecated.json';
32import contractHelpersAbi from '../../abi/contractHelpers.json';33import contractHelpersAbi from '../../abi/contractHelpers.json';
33import {ICrossAccountId, TEthereumAccount} from '../../../util/playgrounds/types';34import {ICrossAccountId, TEthereumAccount} from '../../../util/playgrounds/types';
34import {TCollectionMode} from '../../../util/playgrounds/types';35import {TCollectionMode} from '../../../util/playgrounds/types';
187 return this.collection(this.helper.ethAddress.fromCollectionId(collectionId), mode, caller, mergeDeprecated);188 return this.collection(this.helper.ethAddress.fromCollectionId(collectionId), mode, caller, mergeDeprecated);
188 }189 }
189190
190 async rftToken(address: string, caller?: string) {191 async rftToken(address: string, caller?: string, mergeDeprecated = false) {
191 const web3 = this.helper.getWeb3();192 const web3 = this.helper.getWeb3();
193 const abi = mergeDeprecated ? [...refungibleTokenAbi, ...refungibleTokenDeprecatedAbi] : refungibleTokenAbi;
192 return unlimitedMoneyHack(new web3.eth.Contract(refungibleTokenAbi as any, address, {194 return unlimitedMoneyHack(new web3.eth.Contract(abi as any, address, {
193 gas: this.helper.eth.DEFAULT_GAS,195 gas: this.helper.eth.DEFAULT_GAS,
194 gasPrice: await this.getGasPrice(),196 gasPrice: await this.getGasPrice(),
195 ...(caller ? {from: caller} : {}),197 ...(caller ? {from: caller} : {}),
196 }));198 }));
197 }199 }
198200
199 rftTokenById(collectionId: number, tokenId: number, caller?: string) {201 rftTokenById(collectionId: number, tokenId: number, caller?: string, mergeDeprecated = false) {
200 return this.rftToken(this.helper.ethAddress.fromTokenId(collectionId, tokenId), caller);202 return this.rftToken(this.helper.ethAddress.fromTokenId(collectionId, tokenId), caller, mergeDeprecated);
201 }203 }
202}204}
203205