diff --git a/package.json b/package.json index 7cec978..df6eb92 100644 --- a/package.json +++ b/package.json @@ -31,9 +31,10 @@ "typescript": "^5.3.3" }, "dependencies": { - "@noble/secp256k1": "^2.1.0", + "@noble/secp256k1": "1.7.1", "@uniswap/v3-periphery": "^1.4.4", "ds-test": "github:dapphub/ds-test", + "ethers": "^6.13.2", "forge-std": "github:foundry-rs/forge-std#e8a047e3f40f13fa37af6fe14e6e06283d9a060e", "frax-standard-solidity": "github:FraxFinance/frax-standard-solidity", "fraxtal-contracts": "github:FraxFinance/fraxtal-contracts", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6e09c52..d88437f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,20 +8,23 @@ importers: .: dependencies: "@noble/secp256k1": - specifier: ^2.1.0 - version: 2.1.0 + specifier: 1.7.1 + version: 1.7.1 "@uniswap/v3-periphery": specifier: ^1.4.4 version: 1.4.4 ds-test: specifier: github:dapphub/ds-test version: https://codeload.github.com/dapphub/ds-test/tar.gz/e282159d5170298eb2455a6c05280ab5a73a4ef0 + ethers: + specifier: ^6.13.2 + version: 6.13.2 forge-std: specifier: github:foundry-rs/forge-std#e8a047e3f40f13fa37af6fe14e6e06283d9a060e version: https://codeload.github.com/foundry-rs/forge-std/tar.gz/e8a047e3f40f13fa37af6fe14e6e06283d9a060e frax-standard-solidity: specifier: github:FraxFinance/frax-standard-solidity - version: https://codeload.github.com/FraxFinance/frax-standard-solidity/tar.gz/65b1f01cef3de014a2d6646ebe0ca0df202cc9e6(ethers@6.13.1) + version: https://codeload.github.com/FraxFinance/frax-standard-solidity/tar.gz/65b1f01cef3de014a2d6646ebe0ca0df202cc9e6(ethers@6.13.2) fraxtal-contracts: specifier: github:FraxFinance/fraxtal-contracts version: dev-fraxtal-contracts@https://codeload.github.com/FraxFinance/fraxtal-contracts/tar.gz/d533b607c0d32d10d9a43ada8aa5d6fadf892e8e @@ -277,9 +280,9 @@ packages: { integrity: sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg== } engines: { node: ">= 16" } - "@noble/secp256k1@2.1.0": + "@noble/secp256k1@1.7.1": resolution: - { integrity: sha512-XLEQQNdablO0XZOIniFQimiXsZDNwaYgL96dZwC54Q30imSbAOFf3NKtepc+cXyuZf5Q1HCgbqgZ2UFFuHVcEw== } + { integrity: sha512-hOUk6AyBFmqVrv7k5WAw/LpszxVbj9gGN4JRkIX52fdFAj1UA61KXmZDvqVEm+pOyec3+fIeZB02LYa/pWOArw== } "@openzeppelin/contracts-upgradeable@4.7.3": resolution: @@ -776,9 +779,9 @@ packages: resolution: { integrity: sha512-wswUsmWo1aOK8rR7DIKiWSw9DbLWe6x98Jrn8wcTflTVvaXhAMaB5zGAXy0GYQEQp9iO1iSHWVyARQm11zUtyg== } - ethers@6.13.1: + ethers@6.13.2: resolution: - { integrity: sha512-hdJ2HOxg/xx97Lm9HdCWk949BfYqYWpyw4//78SiwOLgASyfrNszfMUNB2joKjvGUdwhHfaiMMFFwacVVoLR9A== } + { integrity: sha512-9VkriTTed+/27BGuY1s0hf441kqwHJ1wtN2edksEtiRvXx+soxRX3iSXTfFqq2+YwrOqbDoTHjIhQnjJRlzKmg== } engines: { node: ">=14.0.0" } eventemitter3@3.1.2: @@ -1577,9 +1580,9 @@ snapshots: dependencies: regenerator-runtime: 0.14.1 - "@chainlink/contracts@0.6.1(ethers@6.13.1)": + "@chainlink/contracts@0.6.1(ethers@6.13.2)": dependencies: - "@eth-optimism/contracts": 0.5.40(ethers@6.13.1) + "@eth-optimism/contracts": 0.5.40(ethers@6.13.2) "@openzeppelin/contracts": 4.3.3 "@openzeppelin/contracts-upgradeable": 4.9.5 "@openzeppelin/contracts-v0.7": "@openzeppelin/contracts@3.4.2" @@ -1592,12 +1595,12 @@ snapshots: dependencies: "@jridgewell/trace-mapping": 0.3.9 - "@eth-optimism/contracts@0.5.40(ethers@6.13.1)": + "@eth-optimism/contracts@0.5.40(ethers@6.13.2)": dependencies: "@eth-optimism/core-utils": 0.12.0 "@ethersproject/abstract-provider": 5.7.0 "@ethersproject/abstract-signer": 5.7.0 - ethers: 6.13.1 + ethers: 6.13.2 transitivePeerDependencies: - bufferutil - utf-8-validate @@ -1913,7 +1916,7 @@ snapshots: "@noble/hashes@1.4.0": {} - "@noble/secp256k1@2.1.0": {} + "@noble/secp256k1@1.7.1": {} "@openzeppelin/contracts-upgradeable@4.7.3": {} @@ -2333,7 +2336,7 @@ snapshots: - bufferutil - utf-8-validate - ethers@6.13.1: + ethers@6.13.2: dependencies: "@adraffy/ens-normalize": 1.10.1 "@noble/curves": 1.2.0 @@ -2386,9 +2389,9 @@ snapshots: combined-stream: 1.0.8 mime-types: 2.1.35 - frax-standard-solidity@https://codeload.github.com/FraxFinance/frax-standard-solidity/tar.gz/65b1f01cef3de014a2d6646ebe0ca0df202cc9e6(ethers@6.13.1): + frax-standard-solidity@https://codeload.github.com/FraxFinance/frax-standard-solidity/tar.gz/65b1f01cef3de014a2d6646ebe0ca0df202cc9e6(ethers@6.13.2): dependencies: - "@chainlink/contracts": 0.6.1(ethers@6.13.1) + "@chainlink/contracts": 0.6.1(ethers@6.13.2) "@openzeppelin/contracts": 5.0.1 "@types/fs-extra": 11.0.4 "@types/node": 18.19.14 @@ -2890,7 +2893,7 @@ snapshots: axios: 1.7.2 bignumber.js: 9.1.2 ethereum-cryptography: 2.2.1 - ethers: 6.13.1 + ethers: 6.13.2 eventemitter3: 3.1.2 injectpromise: 1.0.0 lodash: 4.17.21 diff --git a/scripts/ERC20PermissionedMint-abi.json b/scripts/ERC20PermissionedMint-abi.json new file mode 100644 index 0000000..1a2f0a5 --- /dev/null +++ b/scripts/ERC20PermissionedMint-abi.json @@ -0,0 +1,277 @@ +[ + { + "inputs": [ + { "internalType": "address", "name": "_creator_address", "type": "address" }, + { "internalType": "address", "name": "_timelock_address", "type": "address" }, + { "internalType": "string", "name": "_name", "type": "string" }, + { "internalType": "string", "name": "_symbol", "type": "string" } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "allowance", "type": "uint256" }, + { "internalType": "uint256", "name": "needed", "type": "uint256" } + ], + "name": "ERC20InsufficientAllowance", + "type": "error" + }, + { + "inputs": [ + { "internalType": "address", "name": "sender", "type": "address" }, + { "internalType": "uint256", "name": "balance", "type": "uint256" }, + { "internalType": "uint256", "name": "needed", "type": "uint256" } + ], + "name": "ERC20InsufficientBalance", + "type": "error" + }, + { + "inputs": [{ "internalType": "address", "name": "approver", "type": "address" }], + "name": "ERC20InvalidApprover", + "type": "error" + }, + { + "inputs": [{ "internalType": "address", "name": "receiver", "type": "address" }], + "name": "ERC20InvalidReceiver", + "type": "error" + }, + { + "inputs": [{ "internalType": "address", "name": "sender", "type": "address" }], + "name": "ERC20InvalidSender", + "type": "error" + }, + { + "inputs": [{ "internalType": "address", "name": "spender", "type": "address" }], + "name": "ERC20InvalidSpender", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "owner", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "spender", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [{ "indexed": false, "internalType": "address", "name": "minter_address", "type": "address" }], + "name": "MinterAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [{ "indexed": false, "internalType": "address", "name": "minter_address", "type": "address" }], + "name": "MinterRemoved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "oldOwner", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "newOwner", "type": "address" } + ], + "name": "OwnerChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [{ "indexed": false, "internalType": "address", "name": "newOwner", "type": "address" }], + "name": "OwnerNominated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "from", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "to", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "TokenMinterBurned", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "from", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "to", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "TokenMinterMinted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "from", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "to", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" } + ], + "name": "Transfer", + "type": "event" + }, + { "inputs": [], "name": "acceptOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [{ "internalType": "address", "name": "minter_address", "type": "address" }], + "name": "addMinter", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "owner", "type": "address" }, + { "internalType": "address", "name": "spender", "type": "address" } + ], + "name": "allowance", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "value", "type": "uint256" } + ], + "name": "approve", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "account", "type": "address" }], + "name": "balanceOf", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "value", "type": "uint256" }], + "name": "burn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "account", "type": "address" }, + { "internalType": "uint256", "name": "value", "type": "uint256" } + ], + "name": "burnFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "m_address", "type": "address" }, + { "internalType": "uint256", "name": "m_amount", "type": "uint256" } + ], + "name": "minter_mint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "minters", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "name": "minters_array", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "_owner", "type": "address" }], + "name": "nominateNewOwner", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "nominatedOwner", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "minter_address", "type": "address" }], + "name": "removeMinter", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "timelock_address", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "value", "type": "uint256" } + ], + "name": "transfer", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "from", "type": "address" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "value", "type": "uint256" } + ], + "name": "transferFrom", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/scripts/tron-tests.js b/scripts/tron-tests.js new file mode 100644 index 0000000..2b56a53 --- /dev/null +++ b/scripts/tron-tests.js @@ -0,0 +1,33 @@ +const TronWeb = require("tronweb"); +// NOTE: "@noble/secp256k1" needs to be @ "1.7.1" +const tronWeb = new TronWeb({ + fullHost: "https://api.trongrid.io", + headers: { "TRON-PRO-API-KEY": process.env.TRONGRID_API_KEY }, + privateKey: process.env.TRON_PK, // as hex string without the 0x +}); + +let abi = require("./ERC20PermissionedMint-abi.json"); +let fraxAddress = "TQZTkTMbkC9923LtVHZcSrdqcW5rVhkZHP"; +let ferryAddress = "TGxtcNUY9q19FATX3tFxzkmBhQigVDTFJs"; + +let fraxAsFullHex = tronWeb.address.toHex(fraxAddress); +let fraxAsEVMHex = "0x".concat(fraxAsFullHex.substr(2)); +console.log(fraxAsEVMHex); // 0xa00c37011018b4b11cffbbf0305a771d9d4066cf + +let deployerAsEVMHex = "0x721fc501d1fe305065dc88da0cf90406a79dfd69"; +let deployerAsFullHex = "41".concat(deployerAsEVMHex.substr(2)); +let deployerAddress = tronWeb.address.fromHex(deployerAsFullHex); +console.log(deployerAddress); // TLNe6KF1dUSYBcZ4fzTstoKB8bkzQewz42 + +async function main() { + let ctr = await tronWeb.contract(abi, fraxAddress); + // View call + let balance = await ctr.balanceOf(ferryAddress).call(); + // ERC20.transfer() call + // https://tronscan.org/#/transaction/a8a22abfda01745cf6475b826a0cc1bfb21ccc7e86be7d87fe76c3fed2976020 + await ctr.transfer(ferryAddress, 123456).send(); +} + +(async function () { + await main(); +})();