diff --git a/.env b/.env new file mode 100644 index 0000000..c703376 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +REACT_APP_CLIENT_ID=BNxdRWx08cSTPlzMAaShlM62d4f8Tp6racfnCg_gaH0XQ1NfSGo3h5B_IkLtgSnPMhlxsSvhqugWm0x8x-VkUXA diff --git a/.vscode/settings.json b/.vscode/settings.json index 02e42b3..41d54e6 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -8,6 +8,6 @@ "typescript.enablePromptUseWorkspaceTsdk": true, "prettier.prettierPath": ".vscode/pnpify/prettier/index.js", "cSpell.words": [ - "Timelock" + ] } diff --git a/assets/wallets/torus.svg b/assets/wallets/torus.svg new file mode 100644 index 0000000..1c0178e --- /dev/null +++ b/assets/wallets/torus.svg @@ -0,0 +1,19 @@ + + + + +Created by potrace 1.16, written by Peter Selinger 2001-2019 + + + + + + diff --git a/packages/arweave-push/.gcloudignore b/packages/arweave-push/.gcloudignore new file mode 100644 index 0000000..0f9ec0f --- /dev/null +++ b/packages/arweave-push/.gcloudignore @@ -0,0 +1,16 @@ +# This file specifies files that are *not* uploaded to Google Cloud Platform +# using gcloud. It follows the same syntax as .gitignore, with the addition of +# "#!include" directives (which insert the entries of the given .gitignore-style +# file at that point). +# +# For more information, run: +# $ gcloud topic gcloudignore +# +.gcloudignore +# If you would like to upload your .git directory, .gitignore file or files +# from your .gitignore file, remove the corresponding line +# below: +.git +.gitignore + +node_modules \ No newline at end of file diff --git a/packages/arweave-push/README b/packages/arweave-push/README new file mode 100644 index 0000000..493040a --- /dev/null +++ b/packages/arweave-push/README @@ -0,0 +1,4 @@ +gcloud functions deploy uploadFile --runtime nodejs12 --trigger-http --allow-unauthenticated + +To deploy to prod, change function name to uploadFileProd in index.js, and CLUSTER url to mainnet, then +run above with uploadFileProd \ No newline at end of file diff --git a/packages/arweave-push/index.js b/packages/arweave-push/index.js new file mode 100644 index 0000000..d159d70 --- /dev/null +++ b/packages/arweave-push/index.js @@ -0,0 +1,348 @@ +// [START functions_http_form_data] +/** + * Parses a 'multipart/form-data' upload request + * + * @param {Object} req Cloud Function request context. + * @param {Object} res Cloud Function response context. + */ +const path = require('path'); +const Arweave = require('arweave'); +const { Storage } = require('@google-cloud/storage'); +const os = require('os'); +const fs = require('fs'); +const crypto = require('crypto'); +const { Account, Connection } = require('@solana/web3.js'); +const mimeType = require('mime-types'); +const fetch = require('node-fetch'); + +const storage = new Storage(); +const BUCKET_NAME = 'us.artifacts.principal-lane-200702.appspot.com'; +const FOLDER_NAME = 'arweave'; +const ARWEAVE_KEYNAME = 'arweave.json'; +const SOLANA_KEYNAME = 'arweave-sol-container.json'; +const CLUSTER = 'https://devnet.solana.com'; +//const CLUSTER = 'https://api.mainnet-beta.solana.com'; +const SYSTEM = '11111111111111111111111111111111'; +const MEMO = 'MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr'; +const KEYHOLDER = {}; +const FAIL = 'fail'; +const SUCCESS = 'success'; +const LAMPORT_MULTIPLIER = 10 ** 9; +const WINSTON_MULTIPLIER = 10 ** 12; +const RESERVED_TXN_MANIFEST = 'manifest.json'; + +function generateManifest(pathMap, indexPath) { + const manifest = { + manifest: 'arweave/paths', + version: '0.1.0', + paths: pathMap, + }; + + if (indexPath) { + if (!Object.keys(pathMap).includes(indexPath)) { + throw new Error( + `--index path not found in directory paths: ${indexPath}`, + ); + } + manifest.index = { + path: indexPath, + }; + } + + return manifest; +} + +const getKey = async function (name) { + if (KEYHOLDER[name]) return KEYHOLDER[name]; + + const options = { + destination: os.tmpdir() + '/' + name, + }; + + // Downloads the file + await storage + .bucket(BUCKET_NAME) + .file(FOLDER_NAME + '/' + name) + .download(options); + + console.log(`Key downloaded to ${os.tmpdir()}/${name}`); + + let rawdata = fs.readFileSync(os.tmpdir() + '/' + name); + let key; + try { + key = JSON.parse(rawdata); + } catch (e) { + key = rawdata.toString(); + } + + KEYHOLDER[name] = key; + return KEYHOLDER[name]; +}; + +// Node.js doesn't have a built-in multipart/form-data parsing library. +// Instead, we can use the 'busboy' library from NPM to parse these requests. +const Busboy = require('busboy'); +const arweaveConnection = Arweave.init({ + host: 'arweave.net', // Hostname or IP address for a Arweave host + port: 443, // Port + protocol: 'https', // Network protocol http or https + timeout: 20000, // Network request timeouts in milliseconds + logging: true, // Enable network request logging +}); + +// FYI no streaming uploads as yet +// https://gist.github.com/CDDelta/e2af7e02314b2e0c3b5f9eb616c645a6 +// Need to read entire thing into memory - Limits us to 2GB files. TODO come back and implemnet. +exports.uploadFile = async (req, res) => { + res.set('Access-Control-Allow-Origin', '*'); + + if (req.method === 'OPTIONS') { + // Send response to OPTIONS requests + res.set('Access-Control-Allow-Methods', 'POST'); + res.set('Access-Control-Allow-Headers', 'Content-Type'); + res.set('Access-Control-Max-Age', '3600'); + res.status(204).send(''); + return; + } + + if (req.method !== 'POST') { + // Return a "method not allowed" error + return res.status(405).end(); + } + const solanaKey = await getKey(SOLANA_KEYNAME); + const solanaConnection = new Connection(CLUSTER, 'recent'); + const solanaWallet = new Account(solanaKey); + const arweaveWallet = await getKey(ARWEAVE_KEYNAME); + console.log('Connections established.'); + const busboy = new Busboy({ headers: req.headers }); + const tmpdir = os.tmpdir(); + + const fieldPromises = []; + + // This code will process each non-file field in the form. + busboy.on('field', (fieldname, val) => { + console.log('I see ' + fieldname); + fieldPromises.push( + new Promise(async (res, _) => { + if (fieldname === 'transaction') { + try { + console.log('Calling out for txn', val); + const transaction = await solanaConnection.getParsedConfirmedTransaction( + val, + ); + console.log('I got the transaction'); + // We expect the first command to be a SOL send from them to our holding account. + // Then after that it's memos of sha256 hashes of file contents. + const expectedSend = + transaction.transaction.message.instructions[0]; + + const isSystem = expectedSend.programId.toBase58() === SYSTEM; + const isToUs = + expectedSend.parsed.info.destination === + solanaWallet.publicKey.toBase58(); + console.log( + 'Expected to send is', + JSON.stringify(expectedSend.parsed), + ); + if (isSystem && isToUs) { + const amount = expectedSend.parsed.info.lamports; + const remainingMemos = transaction.transaction.message.instructions.filter( + i => i.programId.toBase58() === MEMO, + ); + const memoMessages = remainingMemos.map(m => m.parsed); + res({ + name: fieldname, + amount, + memoMessages, + }); + } else + throw new Error( + 'No payment found because either the program wasnt the system program or it wasnt to the holding account', + ); + } catch (e) { + console.log(fieldname, e); + console.log('Setting txn anyway'); + res({ + name: fieldname, + amount: 0, + memoMessages: [], + }); + } + } else if (fieldname === 'tags') { + try { + res({ + name: fieldname, + ...JSON.parse(val), + }); + } catch (e) { + console.log(fieldname, e); + res({ + name: fieldname, + }); + } + } + }), + ); + }); + + const fileWrites = []; + + // This code will process each file uploaded. + busboy.on('file', (fieldname, file, filename) => { + // Note: os.tmpdir() points to an in-memory file system on GCF + // Thus, any files in it must fit in the instance's memory. + console.log(`Processed file ${filename}`); + const filepath = path.join(tmpdir, filename); + + const writeStream = fs.createWriteStream(filepath); + file.pipe(writeStream); + + // File was processed by Busboy; wait for it to be written. + // Note: GCF may not persist saved files across invocations. + // Persistent files must be kept in other locations + // (such as Cloud Storage buckets). + const promise = new Promise((resolve, reject) => { + file.on('end', () => { + writeStream.end(); + }); + writeStream.on('finish', resolve({ status: SUCCESS, filepath })); + writeStream.on( + 'error', + reject({ status: FAIL, filepath, error: 'failed to save' }), + ); + }); + + fileWrites.push(promise); + }); + + // Triggered once all uploaded files are processed by Busboy. + // We still need to wait for the disk writes (saves) to complete. + const body = { messages: [] }; + + busboy.on('finish', async () => { + console.log('Finish'); + const filepaths = [ + ...(await Promise.all(fileWrites)), + { filepath: RESERVED_TXN_MANIFEST, status: SUCCESS }, + ]; + const fields = await Promise.all(fieldPromises); + const anchor = (await arweaveConnection.api.get('tx_anchor')).data; + + console.log('The one guy is ' + fields.map(f => f.name).join(',')); + const txn = fields.find(f => f.name === 'transaction'); + const fieldTags = fields.find(f => f.name === 'tags'); + + if (!txn || !txn.amount) { + body.error = 'No transaction found with payment'; + res.end(JSON.stringify(body)); + return; + } + + let runningTotal = txn.amount; + + const conversionRates = JSON.parse( + await ( + await fetch( + 'https://api.coingecko.com/api/v3/simple/price?ids=solana,arweave&vs_currencies=usd', + ) + ).text(), + ); + + // To figure out how much solana is required, multiply ar byte cost by this number + const arMultiplier = + conversionRates.arweave.usd / conversionRates.solana.usd; + + const paths = {}; + for (let i = 0; i < filepaths.length; i++) { + const f = filepaths[i]; + if (f.status == FAIL) { + body.messages.push(f); + } else { + const { filepath } = f; + const parts = filepath.split('/'); + const filename = parts[parts.length - 1]; + try { + let data, fileSizeInBytes, mime; + if (filepath == RESERVED_TXN_MANIFEST) { + const manifest = await generateManifest(paths, 'metadata.json'); + data = Buffer.from(JSON.stringify(manifest), 'utf8'); + fileSizeInBytes = data.byteLength; + mime = 'application/x.arweave-manifest+json'; + } else { + data = fs.readFileSync(filepath); + + // Have to get separate Buffer since buffers are stateful + const hashSum = crypto.createHash('sha256'); + hashSum.update(data.toString()); + const hex = hashSum.digest('hex'); + + if (!txn.memoMessages.find(m => m === hex)) { + body.messages.push({ + filename, + status: FAIL, + error: `Unable to find proof that you paid for this file, your hash is ${hex}, comparing to ${txn.memoMessages.join( + ',', + )}`, + }); + continue; + } + + const stats = fs.statSync(filepath); + fileSizeInBytes = stats.size; + mime = mimeType.lookup(filepath); + } + + const costSizeInWinstons = parseInt( + await ( + await fetch( + 'https://arweave.net/price/' + fileSizeInBytes.toString(), + ) + ).text(), + ); + + const costToStoreInSolana = + (costSizeInWinstons * arMultiplier) / WINSTON_MULTIPLIER; + + runningTotal -= costToStoreInSolana * LAMPORT_MULTIPLIER; + if (runningTotal > 0) { + const transaction = await arweaveConnection.createTransaction( + { data: data, last_tx: anchor }, + arweaveWallet, + ); + transaction.addTag('Content-Type', mime); + if (fieldTags) { + const tags = + fieldTags[filepath.split('/')[filepath.split('/').length - 1]]; + if (tags) tags.map(t => transaction.addTag(t.name, t.value)); + } + + await arweaveConnection.transactions.sign( + transaction, + arweaveWallet, + ); + await arweaveConnection.transactions.post(transaction); + body.messages.push({ + filename, + status: SUCCESS, + transactionId: transaction.id, + }); + paths[filename] = { id: transaction.id }; + } else { + body.messages.push({ + filename, + status: FAIL, + error: `Not enough funds provided to push this file, you need at least ${costToStoreInSolana} SOL or ${costSize} AR`, + }); + } + } catch (e) { + console.log(e); + body.messages.push({ filename, status: FAIL, error: e.toString() }); + } + } + } + + res.end(JSON.stringify(body)); + }); + busboy.end(req.rawBody); +}; +// [END functions_http_form_data] diff --git a/packages/arweave-push/package.json b/packages/arweave-push/package.json new file mode 100644 index 0000000..55b0c41 --- /dev/null +++ b/packages/arweave-push/package.json @@ -0,0 +1,32 @@ +{ + "name": "arweave-push", + "version": "0.0.1", + "private": true, + "license": "Apache-2.0", + "author": "Solana Labs", + "repository": { + "type": "git", + "url": "https://github.com/solana-labs/oyster.git" + }, + "engines": { + "node": ">=12.0.0" + }, + "scripts": { + "test": "mocha test/*.test.js --timeout=60000" + }, + "devDependencies": { + "mocha": "^8.0.0", + "proxyquire": "^2.1.0", + "sinon": "^10.0.0" + }, + "dependencies": { + "@google-cloud/storage": "^5.0.0", + "busboy": "^0.3.0", + "escape-html": "^1.0.3", + "arweave": "1.10.13", + "@solana/web3.js": "^1.5.0", + "mime-types": "2.1.30", + "node-fetch": "2.6.1", + "coingecko-api": "1.0.10" + } +} diff --git a/packages/bridge/contracts/Address.json b/packages/bridge-sdk/contracts/Address.json similarity index 95% rename from packages/bridge/contracts/Address.json rename to packages/bridge-sdk/contracts/Address.json index e389244..dad0604 100644 --- a/packages/bridge/contracts/Address.json +++ b/packages/bridge-sdk/contracts/Address.json @@ -12,9 +12,7 @@ "ast": { "absolutePath": "@openzeppelin/contracts/utils/Address.sol", "exportedSymbols": { - "Address": [ - 3595 - ] + "Address": [3595] }, "id": 3596, "license": "MIT", @@ -22,15 +20,7 @@ "nodes": [ { "id": 3301, - "literals": [ - "solidity", - ">=", - "0.6", - ".2", - "<", - "0.8", - ".0" - ], + "literals": ["solidity", ">=", "0.6", ".2", "<", "0.8", ".0"], "nodeType": "PragmaDirective", "src": "33:31:8" }, @@ -47,9 +37,7 @@ }, "fullyImplemented": true, "id": 3595, - "linearizedBaseContracts": [ - 3595 - ], + "linearizedBaseContracts": [3595], "name": "Address", "nodeType": "ContractDefinition", "nodes": [ @@ -60,9 +48,7 @@ "src": "792:347:8", "statements": [ { - "assignments": [ - 3311 - ], + "assignments": [3311], "declarations": [ { "constant": false, @@ -453,10 +439,7 @@ "id": 3327, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "2137:7:8", "typeDescriptions": { @@ -484,10 +467,7 @@ "src": "2137:73:8" }, { - "assignments": [ - 3339, - null - ], + "assignments": [3339, null], "declarations": [ { "constant": false, @@ -588,9 +568,7 @@ "isLValue": false, "isPure": false, "lValueRequested": false, - "names": [ - "value" - ], + "names": ["value"], "nodeType": "FunctionCallOptions", "options": [ { @@ -681,10 +659,7 @@ "id": 3347, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "2362:7:8", "typeDescriptions": { @@ -875,10 +850,7 @@ "id": 3363, "name": "functionCall", "nodeType": "Identifier", - "overloadedDeclarations": [ - 3370, - 3390 - ], + "overloadedDeclarations": [3370, 3390], "referencedDeclaration": 3390, "src": "3292:12:8", "typeDescriptions": { @@ -1116,10 +1088,7 @@ "id": 3382, "name": "functionCallWithValue", "nodeType": "Identifier", - "overloadedDeclarations": [ - 3410, - 3460 - ], + "overloadedDeclarations": [3410, 3460], "referencedDeclaration": 3460, "src": "3715:21:8", "typeDescriptions": { @@ -1385,10 +1354,7 @@ "id": 3402, "name": "functionCallWithValue", "nodeType": "Identifier", - "overloadedDeclarations": [ - 3410, - 3460 - ], + "overloadedDeclarations": [3410, 3460], "referencedDeclaration": 3460, "src": "4266:21:8", "typeDescriptions": { @@ -1716,10 +1682,7 @@ "id": 3424, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "4759:7:8", "typeDescriptions": { @@ -1833,10 +1796,7 @@ "id": 3435, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "4850:7:8", "typeDescriptions": { @@ -1864,10 +1824,7 @@ "src": "4850:60:8" }, { - "assignments": [ - 3443, - 3445 - ], + "assignments": [3443, 3445], "declarations": [ { "constant": false, @@ -1990,9 +1947,7 @@ "isLValue": false, "isPure": false, "lValueRequested": false, - "names": [ - "value" - ], + "names": ["value"], "nodeType": "FunctionCallOptions", "options": [ { @@ -2372,10 +2327,7 @@ "id": 3470, "name": "functionStaticCall", "nodeType": "Identifier", - "overloadedDeclarations": [ - 3477, - 3512 - ], + "overloadedDeclarations": [3477, 3512], "referencedDeclaration": 3512, "src": "5425:18:8", "typeDescriptions": { @@ -2616,10 +2568,7 @@ "id": 3489, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "5827:7:8", "typeDescriptions": { @@ -2647,10 +2596,7 @@ "src": "5827:67:8" }, { - "assignments": [ - 3497, - 3499 - ], + "assignments": [3497, 3499], "declarations": [ { "constant": false, @@ -3090,10 +3036,7 @@ "id": 3522, "name": "functionDelegateCall", "nodeType": "Identifier", - "overloadedDeclarations": [ - 3529, - 3564 - ], + "overloadedDeclarations": [3529, 3564], "referencedDeclaration": 3564, "src": "6398:20:8", "typeDescriptions": { @@ -3334,10 +3277,7 @@ "id": 3541, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "6803:7:8", "typeDescriptions": { @@ -3365,10 +3305,7 @@ "src": "6803:69:8" }, { - "assignments": [ - 3549, - 3551 - ], + "assignments": [3549, 3551], "declarations": [ { "constant": false, @@ -3860,10 +3797,7 @@ "id": 3585, "name": "revert", "nodeType": "Identifier", - "overloadedDeclarations": [ - -19, - -19 - ], + "overloadedDeclarations": [-19, -19], "referencedDeclaration": -19, "src": "7765:6:8", "typeDescriptions": { @@ -4187,24 +4121,14 @@ "attributes": { "absolutePath": "@openzeppelin/contracts/utils/Address.sol", "exportedSymbols": { - "Address": [ - 3595 - ] + "Address": [3595] }, "license": "MIT" }, "children": [ { "attributes": { - "literals": [ - "solidity", - ">=", - "0.6", - ".2", - "<", - "0.8", - ".0" - ] + "literals": ["solidity", ">=", "0.6", ".2", "<", "0.8", ".0"] }, "id": 3301, "name": "PragmaDirective", @@ -4213,17 +4137,11 @@ { "attributes": { "abstract": false, - "baseContracts": [ - null - ], - "contractDependencies": [ - null - ], + "baseContracts": [null], + "contractDependencies": [null], "contractKind": "library", "fullyImplemented": true, - "linearizedBaseContracts": [ - 3595 - ], + "linearizedBaseContracts": [3595], "name": "Address", "scope": 3596 }, @@ -4241,9 +4159,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "isContract", "overrides": null, "scope": 3595, @@ -4335,9 +4251,7 @@ "children": [ { "attributes": { - "assignments": [ - 3311 - ], + "assignments": [3311], "initialValue": null }, "children": [ @@ -4423,9 +4337,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3311, "type": "uint256", "value": "size" @@ -4476,9 +4388,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "sendValue", "overrides": null, "scope": 3595, @@ -4561,9 +4471,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 3326, @@ -4582,9 +4490,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -4602,10 +4508,7 @@ "typeString": "literal_string \"Address: insufficient balance\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -4649,9 +4552,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address", "type_conversion": true @@ -4689,9 +4590,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -28, "type": "library Address", "value": "this" @@ -4713,9 +4612,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3324, "type": "uint256", "value": "amount" @@ -4758,10 +4655,7 @@ }, { "attributes": { - "assignments": [ - 3339, - null - ] + "assignments": [3339, null] }, "children": [ { @@ -4800,9 +4694,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple(bool,bytes memory)", "type_conversion": false @@ -4820,9 +4712,7 @@ "isLValue": false, "isPure": false, "lValueRequested": false, - "names": [ - "value" - ], + "names": ["value"], "type": "function (bytes memory) payable returns (bool,bytes memory)" }, "children": [ @@ -4846,9 +4736,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3322, "type": "address payable", "value": "recipient" @@ -4865,9 +4753,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3324, "type": "uint256", "value": "amount" @@ -4918,9 +4804,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -4938,10 +4822,7 @@ "typeString": "literal_string \"Address: unable to send value, recipient may have reverted\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -4953,9 +4834,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3339, "type": "bool", "value": "success" @@ -5006,9 +4885,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "functionCall", "overrides": null, "scope": 3595, @@ -5139,9 +5016,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes memory", "type_conversion": false @@ -5163,10 +5038,7 @@ "typeString": "literal_string \"Address: low-level call failed\"" } ], - "overloadedDeclarations": [ - 3370, - 3390 - ], + "overloadedDeclarations": [3370, 3390], "referencedDeclaration": 3390, "type": "function (address,bytes memory,string memory) returns (bytes memory)", "value": "functionCall" @@ -5178,9 +5050,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3356, "type": "address", "value": "target" @@ -5192,9 +5062,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3358, "type": "bytes memory", "value": "data" @@ -5245,9 +5113,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "functionCall", "overrides": null, "scope": 3595, @@ -5406,9 +5272,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes memory", "type_conversion": false @@ -5434,10 +5298,7 @@ "typeString": "string memory" } ], - "overloadedDeclarations": [ - 3410, - 3460 - ], + "overloadedDeclarations": [3410, 3460], "referencedDeclaration": 3460, "type": "function (address,bytes memory,uint256,string memory) returns (bytes memory)", "value": "functionCallWithValue" @@ -5449,9 +5310,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3373, "type": "address", "value": "target" @@ -5463,9 +5322,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3375, "type": "bytes memory", "value": "data" @@ -5494,9 +5351,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3377, "type": "string memory", "value": "errorMessage" @@ -5530,9 +5385,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "functionCallWithValue", "overrides": null, "scope": 3595, @@ -5691,9 +5544,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes memory", "type_conversion": false @@ -5719,10 +5570,7 @@ "typeString": "literal_string \"Address: low-level call with value failed\"" } ], - "overloadedDeclarations": [ - 3410, - 3460 - ], + "overloadedDeclarations": [3410, 3460], "referencedDeclaration": 3460, "type": "function (address,bytes memory,uint256,string memory) returns (bytes memory)", "value": "functionCallWithValue" @@ -5734,9 +5582,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3393, "type": "address", "value": "target" @@ -5748,9 +5594,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3395, "type": "bytes memory", "value": "data" @@ -5762,9 +5606,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3397, "type": "uint256", "value": "value" @@ -5815,9 +5657,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "functionCallWithValue", "overrides": null, "scope": 3595, @@ -6001,9 +5841,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -6021,10 +5859,7 @@ "typeString": "literal_string \"Address: insufficient balance for call\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -6068,9 +5903,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address", "type_conversion": true @@ -6108,9 +5941,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -28, "type": "library Address", "value": "this" @@ -6132,9 +5963,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3417, "type": "uint256", "value": "value" @@ -6185,9 +6014,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -6205,10 +6032,7 @@ "typeString": "literal_string \"Address: call to non-contract\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -6225,9 +6049,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bool", "type_conversion": false @@ -6241,9 +6063,7 @@ "typeString": "address" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3319, "type": "function (address) view returns (bool)", "value": "isContract" @@ -6255,9 +6075,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3413, "type": "address", "value": "target" @@ -6300,10 +6118,7 @@ }, { "attributes": { - "assignments": [ - 3443, - 3445 - ] + "assignments": [3443, 3445] }, "children": [ { @@ -6370,9 +6185,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple(bool,bytes memory)", "type_conversion": false @@ -6390,9 +6203,7 @@ "isLValue": false, "isPure": false, "lValueRequested": false, - "names": [ - "value" - ], + "names": ["value"], "type": "function (bytes memory) payable returns (bool,bytes memory)" }, "children": [ @@ -6416,9 +6227,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3413, "type": "address", "value": "target" @@ -6435,9 +6244,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3417, "type": "uint256", "value": "value" @@ -6454,9 +6261,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3415, "type": "bytes memory", "value": "data" @@ -6488,9 +6293,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes memory", "type_conversion": false @@ -6512,9 +6315,7 @@ "typeString": "string memory" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3594, "type": "function (bool,bytes memory,string memory) pure returns (bytes memory)", "value": "_verifyCallResult" @@ -6526,9 +6327,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3443, "type": "bool", "value": "success" @@ -6540,9 +6339,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3445, "type": "bytes memory", "value": "returndata" @@ -6554,9 +6351,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3419, "type": "string memory", "value": "errorMessage" @@ -6590,9 +6385,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "functionStaticCall", "overrides": null, "scope": 3595, @@ -6723,9 +6516,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes memory", "type_conversion": false @@ -6747,10 +6538,7 @@ "typeString": "literal_string \"Address: low-level static call failed\"" } ], - "overloadedDeclarations": [ - 3477, - 3512 - ], + "overloadedDeclarations": [3477, 3512], "referencedDeclaration": 3512, "type": "function (address,bytes memory,string memory) view returns (bytes memory)", "value": "functionStaticCall" @@ -6762,9 +6550,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3463, "type": "address", "value": "target" @@ -6776,9 +6562,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3465, "type": "bytes memory", "value": "data" @@ -6829,9 +6613,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "functionStaticCall", "overrides": null, "scope": 3595, @@ -6987,9 +6769,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -7007,10 +6787,7 @@ "typeString": "literal_string \"Address: static call to non-contract\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -7027,9 +6804,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bool", "type_conversion": false @@ -7043,9 +6818,7 @@ "typeString": "address" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3319, "type": "function (address) view returns (bool)", "value": "isContract" @@ -7057,9 +6830,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3480, "type": "address", "value": "target" @@ -7102,10 +6873,7 @@ }, { "attributes": { - "assignments": [ - 3497, - 3499 - ] + "assignments": [3497, 3499] }, "children": [ { @@ -7172,9 +6940,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple(bool,bytes memory)", "type_conversion": false @@ -7200,9 +6966,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3480, "type": "address", "value": "target" @@ -7219,9 +6983,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3482, "type": "bytes memory", "value": "data" @@ -7253,9 +7015,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes memory", "type_conversion": false @@ -7277,9 +7037,7 @@ "typeString": "string memory" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3594, "type": "function (bool,bytes memory,string memory) pure returns (bytes memory)", "value": "_verifyCallResult" @@ -7291,9 +7049,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3497, "type": "bool", "value": "success" @@ -7305,9 +7061,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3499, "type": "bytes memory", "value": "returndata" @@ -7319,9 +7073,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3484, "type": "string memory", "value": "errorMessage" @@ -7355,9 +7107,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "functionDelegateCall", "overrides": null, "scope": 3595, @@ -7488,9 +7238,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes memory", "type_conversion": false @@ -7512,10 +7260,7 @@ "typeString": "literal_string \"Address: low-level delegate call failed\"" } ], - "overloadedDeclarations": [ - 3529, - 3564 - ], + "overloadedDeclarations": [3529, 3564], "referencedDeclaration": 3564, "type": "function (address,bytes memory,string memory) returns (bytes memory)", "value": "functionDelegateCall" @@ -7527,9 +7272,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3515, "type": "address", "value": "target" @@ -7541,9 +7284,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3517, "type": "bytes memory", "value": "data" @@ -7594,9 +7335,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "functionDelegateCall", "overrides": null, "scope": 3595, @@ -7752,9 +7491,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -7772,10 +7509,7 @@ "typeString": "literal_string \"Address: delegate call to non-contract\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -7792,9 +7526,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bool", "type_conversion": false @@ -7808,9 +7540,7 @@ "typeString": "address" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3319, "type": "function (address) view returns (bool)", "value": "isContract" @@ -7822,9 +7552,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3532, "type": "address", "value": "target" @@ -7867,10 +7595,7 @@ }, { "attributes": { - "assignments": [ - 3549, - 3551 - ] + "assignments": [3549, 3551] }, "children": [ { @@ -7937,9 +7662,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple(bool,bytes memory)", "type_conversion": false @@ -7965,9 +7688,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3532, "type": "address", "value": "target" @@ -7984,9 +7705,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3534, "type": "bytes memory", "value": "data" @@ -8018,9 +7737,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes memory", "type_conversion": false @@ -8042,9 +7759,7 @@ "typeString": "string memory" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3594, "type": "function (bool,bytes memory,string memory) pure returns (bytes memory)", "value": "_verifyCallResult" @@ -8056,9 +7771,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3549, "type": "bool", "value": "success" @@ -8070,9 +7783,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3551, "type": "bytes memory", "value": "returndata" @@ -8084,9 +7795,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3536, "type": "string memory", "value": "errorMessage" @@ -8121,9 +7830,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "_verifyCallResult", "overrides": null, "scope": 3595, @@ -8265,9 +7972,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3566, "type": "bool", "value": "success" @@ -8286,9 +7991,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3568, "type": "bytes memory", "value": "returndata" @@ -8341,9 +8044,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3568, "type": "bytes memory", "value": "returndata" @@ -8424,9 +8125,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -8455,9 +8154,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3570, "type": "string memory", "value": "errorMessage" @@ -8534,4 +8231,4 @@ "methods": {}, "version": 1 } -} \ No newline at end of file +} diff --git a/packages/bridge/contracts/BytesLib.json b/packages/bridge-sdk/contracts/BytesLib.json similarity index 98% rename from packages/bridge/contracts/BytesLib.json rename to packages/bridge-sdk/contracts/BytesLib.json index ed522e8..86195cf 100644 --- a/packages/bridge/contracts/BytesLib.json +++ b/packages/bridge-sdk/contracts/BytesLib.json @@ -12,9 +12,7 @@ "ast": { "absolutePath": "/Users/bartosz.lipinski/Workspace/wormhole/ethereum/contracts/BytesLib.sol", "exportedSymbols": { - "BytesLib": [ - 333 - ] + "BytesLib": [333] }, "id": 334, "license": "Unlicense", @@ -22,15 +20,7 @@ "nodes": [ { "id": 1, - "literals": [ - "solidity", - ">=", - "0.5", - ".0", - "<", - "0.7", - ".0" - ], + "literals": ["solidity", ">=", "0.5", ".0", "<", "0.7", ".0"], "nodeType": "PragmaDirective", "src": "336:31:0" }, @@ -42,9 +32,7 @@ "documentation": null, "fullyImplemented": true, "id": 333, - "linearizedBaseContracts": [ - 333 - ], + "linearizedBaseContracts": [333], "name": "BytesLib", "nodeType": "ContractDefinition", "nodes": [ @@ -55,9 +43,7 @@ "src": "533:2695:0", "statements": [ { - "assignments": [ - 11 - ], + "assignments": [11], "declarations": [ { "constant": false, @@ -3469,10 +3455,7 @@ "id": 37, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "9027:7:0", "typeDescriptions": { @@ -3500,9 +3483,7 @@ "src": "9027:66:0" }, { - "assignments": [ - 49 - ], + "assignments": [49], "declarations": [ { "constant": false, @@ -4587,10 +4568,7 @@ "id": 64, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "11449:7:0", "typeDescriptions": { @@ -4618,9 +4596,7 @@ "src": "11449:61:0" }, { - "assignments": [ - 76 - ], + "assignments": [76], "declarations": [ { "constant": false, @@ -5063,10 +5039,7 @@ "id": 91, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "11804:7:0", "typeDescriptions": { @@ -5094,9 +5067,7 @@ "src": "11804:60:0" }, { - "assignments": [ - 103 - ], + "assignments": [103], "declarations": [ { "constant": false, @@ -5519,10 +5490,7 @@ "id": 118, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "12114:7:0", "typeDescriptions": { @@ -5550,9 +5518,7 @@ "src": "12114:60:0" }, { - "assignments": [ - 130 - ], + "assignments": [130], "declarations": [ { "constant": false, @@ -5975,10 +5941,7 @@ "id": 145, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "12425:7:0", "typeDescriptions": { @@ -6006,9 +5969,7 @@ "src": "12425:60:0" }, { - "assignments": [ - 157 - ], + "assignments": [157], "declarations": [ { "constant": false, @@ -6431,10 +6392,7 @@ "id": 172, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "12736:7:0", "typeDescriptions": { @@ -6462,9 +6420,7 @@ "src": "12736:60:0" }, { - "assignments": [ - 184 - ], + "assignments": [184], "declarations": [ { "constant": false, @@ -6887,10 +6843,7 @@ "id": 199, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "13047:7:0", "typeDescriptions": { @@ -6918,9 +6871,7 @@ "src": "13047:61:0" }, { - "assignments": [ - 211 - ], + "assignments": [211], "declarations": [ { "constant": false, @@ -7343,10 +7294,7 @@ "id": 226, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "13361:7:0", "typeDescriptions": { @@ -7374,9 +7322,7 @@ "src": "13361:61:0" }, { - "assignments": [ - 238 - ], + "assignments": [238], "declarations": [ { "constant": false, @@ -7799,10 +7745,7 @@ "id": 253, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "13677:7:0", "typeDescriptions": { @@ -7830,9 +7773,7 @@ "src": "13677:61:0" }, { - "assignments": [ - 265 - ], + "assignments": [265], "declarations": [ { "constant": false, @@ -8255,10 +8196,7 @@ "id": 280, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "13993:7:0", "typeDescriptions": { @@ -8286,9 +8224,7 @@ "src": "13993:61:0" }, { - "assignments": [ - 292 - ], + "assignments": [292], "declarations": [ { "constant": false, @@ -8560,9 +8496,7 @@ "src": "14313:1291:0", "statements": [ { - "assignments": [ - 308 - ], + "assignments": [308], "declarations": [ { "constant": false, @@ -9290,9 +9224,7 @@ "src": "15749:2491:0", "statements": [ { - "assignments": [ - 325 - ], + "assignments": [325], "declarations": [ { "constant": false, @@ -10434,24 +10366,14 @@ "attributes": { "absolutePath": "/Users/bartosz.lipinski/Workspace/wormhole/ethereum/contracts/BytesLib.sol", "exportedSymbols": { - "BytesLib": [ - 333 - ] + "BytesLib": [333] }, "license": "Unlicense" }, "children": [ { "attributes": { - "literals": [ - "solidity", - ">=", - "0.5", - ".0", - "<", - "0.7", - ".0" - ] + "literals": ["solidity", ">=", "0.5", ".0", "<", "0.7", ".0"] }, "id": 1, "name": "PragmaDirective", @@ -10460,18 +10382,12 @@ { "attributes": { "abstract": false, - "baseContracts": [ - null - ], - "contractDependencies": [ - null - ], + "baseContracts": [null], + "contractDependencies": [null], "contractKind": "library", "documentation": null, "fullyImplemented": true, - "linearizedBaseContracts": [ - 333 - ], + "linearizedBaseContracts": [333], "name": "BytesLib", "scope": 334 }, @@ -10482,9 +10398,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "concat", "overrides": null, "scope": 333, @@ -10595,9 +10509,7 @@ "children": [ { "attributes": { - "assignments": [ - 11 - ], + "assignments": [11], "initialValue": null }, "children": [ @@ -10724,9 +10636,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 11, "type": "bytes memory", "value": "tempBytes" @@ -10756,9 +10666,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "concatStorage", "overrides": null, "scope": 333, @@ -10832,9 +10740,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 23, @@ -10955,9 +10861,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "slice", "overrides": null, "scope": 333, @@ -11104,9 +11008,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -11124,10 +11026,7 @@ "typeString": "literal_string \"Read out of bounds\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -11166,9 +11065,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 28, "type": "bytes memory", "value": "_bytes" @@ -11211,9 +11108,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 30, "type": "uint256", "value": "_start" @@ -11225,9 +11120,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 32, "type": "uint256", "value": "_length" @@ -11280,9 +11173,7 @@ }, { "attributes": { - "assignments": [ - 49 - ], + "assignments": [49], "initialValue": null }, "children": [ @@ -11416,9 +11307,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 49, "type": "bytes memory", "value": "tempBytes" @@ -11448,9 +11337,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "toAddress", "overrides": null, "scope": 333, @@ -11570,9 +11457,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -11590,10 +11475,7 @@ "typeString": "literal_string \"Read out of bounds\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -11632,9 +11514,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 57, "type": "bytes memory", "value": "_bytes" @@ -11677,9 +11557,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 59, "type": "uint256", "value": "_start" @@ -11749,9 +11627,7 @@ }, { "attributes": { - "assignments": [ - 76 - ], + "assignments": [76], "initialValue": null }, "children": [ @@ -11830,9 +11706,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 76, "type": "address", "value": "tempAddress" @@ -11862,9 +11736,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "toUint8", "overrides": null, "scope": 333, @@ -11983,9 +11855,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -12003,10 +11873,7 @@ "typeString": "literal_string \"Read out of bounds\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -12045,9 +11912,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 84, "type": "bytes memory", "value": "_bytes" @@ -12090,9 +11955,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 86, "type": "uint256", "value": "_start" @@ -12162,9 +12025,7 @@ }, { "attributes": { - "assignments": [ - 103 - ], + "assignments": [103], "initialValue": null }, "children": [ @@ -12242,9 +12103,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 103, "type": "uint8", "value": "tempUint" @@ -12274,9 +12133,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "toUint16", "overrides": null, "scope": 333, @@ -12395,9 +12252,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -12415,10 +12270,7 @@ "typeString": "literal_string \"Read out of bounds\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -12457,9 +12309,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 111, "type": "bytes memory", "value": "_bytes" @@ -12502,9 +12352,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 113, "type": "uint256", "value": "_start" @@ -12574,9 +12422,7 @@ }, { "attributes": { - "assignments": [ - 130 - ], + "assignments": [130], "initialValue": null }, "children": [ @@ -12654,9 +12500,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 130, "type": "uint16", "value": "tempUint" @@ -12686,9 +12530,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "toUint32", "overrides": null, "scope": 333, @@ -12807,9 +12649,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -12827,10 +12667,7 @@ "typeString": "literal_string \"Read out of bounds\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -12869,9 +12706,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 138, "type": "bytes memory", "value": "_bytes" @@ -12914,9 +12749,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 140, "type": "uint256", "value": "_start" @@ -12986,9 +12819,7 @@ }, { "attributes": { - "assignments": [ - 157 - ], + "assignments": [157], "initialValue": null }, "children": [ @@ -13066,9 +12897,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 157, "type": "uint32", "value": "tempUint" @@ -13098,9 +12927,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "toUint64", "overrides": null, "scope": 333, @@ -13219,9 +13046,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -13239,10 +13064,7 @@ "typeString": "literal_string \"Read out of bounds\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -13281,9 +13103,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 165, "type": "bytes memory", "value": "_bytes" @@ -13326,9 +13146,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 167, "type": "uint256", "value": "_start" @@ -13398,9 +13216,7 @@ }, { "attributes": { - "assignments": [ - 184 - ], + "assignments": [184], "initialValue": null }, "children": [ @@ -13478,9 +13294,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 184, "type": "uint64", "value": "tempUint" @@ -13510,9 +13324,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "toUint96", "overrides": null, "scope": 333, @@ -13631,9 +13443,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -13651,10 +13461,7 @@ "typeString": "literal_string \"Read out of bounds\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -13693,9 +13500,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 192, "type": "bytes memory", "value": "_bytes" @@ -13738,9 +13543,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 194, "type": "uint256", "value": "_start" @@ -13810,9 +13613,7 @@ }, { "attributes": { - "assignments": [ - 211 - ], + "assignments": [211], "initialValue": null }, "children": [ @@ -13890,9 +13691,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 211, "type": "uint96", "value": "tempUint" @@ -13922,9 +13721,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "toUint128", "overrides": null, "scope": 333, @@ -14043,9 +13840,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -14063,10 +13858,7 @@ "typeString": "literal_string \"Read out of bounds\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -14105,9 +13897,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 219, "type": "bytes memory", "value": "_bytes" @@ -14150,9 +13940,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 221, "type": "uint256", "value": "_start" @@ -14222,9 +14010,7 @@ }, { "attributes": { - "assignments": [ - 238 - ], + "assignments": [238], "initialValue": null }, "children": [ @@ -14302,9 +14088,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 238, "type": "uint128", "value": "tempUint" @@ -14334,9 +14118,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "toUint256", "overrides": null, "scope": 333, @@ -14455,9 +14237,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -14475,10 +14255,7 @@ "typeString": "literal_string \"Read out of bounds\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -14517,9 +14294,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 246, "type": "bytes memory", "value": "_bytes" @@ -14562,9 +14337,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 248, "type": "uint256", "value": "_start" @@ -14634,9 +14407,7 @@ }, { "attributes": { - "assignments": [ - 265 - ], + "assignments": [265], "initialValue": null }, "children": [ @@ -14714,9 +14485,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 265, "type": "uint256", "value": "tempUint" @@ -14746,9 +14515,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "toBytes32", "overrides": null, "scope": 333, @@ -14867,9 +14634,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -14887,10 +14652,7 @@ "typeString": "literal_string \"Read out of bounds\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -14929,9 +14691,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 273, "type": "bytes memory", "value": "_bytes" @@ -14974,9 +14734,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 275, "type": "uint256", "value": "_start" @@ -15046,9 +14804,7 @@ }, { "attributes": { - "assignments": [ - 292 - ], + "assignments": [292], "initialValue": null }, "children": [ @@ -15126,9 +14882,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 292, "type": "bytes32", "value": "tempBytes32" @@ -15158,9 +14912,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "equal", "overrides": null, "scope": 333, @@ -15271,9 +15023,7 @@ "children": [ { "attributes": { - "assignments": [ - 308 - ] + "assignments": [308] }, "children": [ { @@ -15388,9 +15138,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 308, "type": "bool", "value": "success" @@ -15420,9 +15168,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "equalStorage", "overrides": null, "scope": 333, @@ -15533,9 +15279,7 @@ "children": [ { "attributes": { - "assignments": [ - 325 - ] + "assignments": [325] }, "children": [ { @@ -15664,9 +15408,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 325, "type": "bool", "value": "success" @@ -15717,4 +15459,4 @@ "methods": {}, "version": 1 } -} \ No newline at end of file +} diff --git a/packages/bridge/contracts/Context.json b/packages/bridge-sdk/contracts/Context.json similarity index 93% rename from packages/bridge/contracts/Context.json rename to packages/bridge-sdk/contracts/Context.json index ed096de..40a9d55 100644 --- a/packages/bridge/contracts/Context.json +++ b/packages/bridge-sdk/contracts/Context.json @@ -12,9 +12,7 @@ "ast": { "absolutePath": "@openzeppelin/contracts/utils/Context.sol", "exportedSymbols": { - "Context": [ - 3618 - ] + "Context": [3618] }, "id": 3619, "license": "MIT", @@ -22,15 +20,7 @@ "nodes": [ { "id": 3597, - "literals": [ - "solidity", - ">=", - "0.6", - ".0", - "<", - "0.8", - ".0" - ], + "literals": ["solidity", ">=", "0.6", ".0", "<", "0.8", ".0"], "nodeType": "PragmaDirective", "src": "33:31:9" }, @@ -42,9 +32,7 @@ "documentation": null, "fullyImplemented": true, "id": 3618, - "linearizedBaseContracts": [ - 3618 - ], + "linearizedBaseContracts": [3618], "name": "Context", "nodeType": "ContractDefinition", "nodes": [ @@ -274,24 +262,14 @@ "attributes": { "absolutePath": "@openzeppelin/contracts/utils/Context.sol", "exportedSymbols": { - "Context": [ - 3618 - ] + "Context": [3618] }, "license": "MIT" }, "children": [ { "attributes": { - "literals": [ - "solidity", - ">=", - "0.6", - ".0", - "<", - "0.8", - ".0" - ] + "literals": ["solidity", ">=", "0.6", ".0", "<", "0.8", ".0"] }, "id": 3597, "name": "PragmaDirective", @@ -300,18 +278,12 @@ { "attributes": { "abstract": true, - "baseContracts": [ - null - ], - "contractDependencies": [ - null - ], + "baseContracts": [null], + "contractDependencies": [null], "contractKind": "contract", "documentation": null, "fullyImplemented": true, - "linearizedBaseContracts": [ - 3618 - ], + "linearizedBaseContracts": [3618], "name": "Context", "scope": 3619 }, @@ -322,9 +294,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "_msgSender", "overrides": null, "scope": 3618, @@ -335,9 +305,7 @@ "children": [ { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 3598, @@ -402,9 +370,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -15, "type": "msg", "value": "msg" @@ -439,9 +405,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "_msgData", "overrides": null, "scope": 3618, @@ -452,9 +416,7 @@ "children": [ { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 3607, @@ -503,9 +465,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -28, "type": "contract Context", "value": "this" @@ -539,9 +499,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -15, "type": "msg", "value": "msg" @@ -597,4 +555,4 @@ "methods": {}, "version": 1 } -} \ No newline at end of file +} diff --git a/packages/bridge/contracts/ERC20.json b/packages/bridge-sdk/contracts/ERC20.json similarity index 95% rename from packages/bridge/contracts/ERC20.json rename to packages/bridge-sdk/contracts/ERC20.json index d320c94..28c8a8c 100644 --- a/packages/bridge/contracts/ERC20.json +++ b/packages/bridge-sdk/contracts/ERC20.json @@ -299,9 +299,7 @@ "ast": { "absolutePath": "@openzeppelin/contracts/token/ERC20/ERC20.sol", "exportedSymbols": { - "ERC20": [ - 3008 - ] + "ERC20": [3008] }, "id": 3009, "license": "MIT", @@ -309,15 +307,7 @@ "nodes": [ { "id": 2507, - "literals": [ - "solidity", - ">=", - "0.6", - ".0", - "<", - "0.8", - ".0" - ], + "literals": ["solidity", ">=", "0.6", ".0", "<", "0.8", ".0"], "nodeType": "PragmaDirective", "src": "33:31:5" }, @@ -394,10 +384,7 @@ "src": "1348:6:5" } ], - "contractDependencies": [ - 3086, - 3618 - ], + "contractDependencies": [3086, 3618], "contractKind": "contract", "documentation": { "id": 2511, @@ -407,11 +394,7 @@ }, "fullyImplemented": true, "id": 3008, - "linearizedBaseContracts": [ - 3008, - 3086, - 3618 - ], + "linearizedBaseContracts": [3008, 3086, 3618], "name": "ERC20", "nodeType": "ContractDefinition", "nodes": [ @@ -1171,9 +1154,7 @@ "visibility": "public" }, { - "baseFunctions": [ - 3017 - ], + "baseFunctions": [3017], "body": { "id": 2593, "nodeType": "Block", @@ -1267,9 +1248,7 @@ "visibility": "public" }, { - "baseFunctions": [ - 3025 - ], + "baseFunctions": [3025], "body": { "id": 2607, "nodeType": "Block", @@ -1420,9 +1399,7 @@ "visibility": "public" }, { - "baseFunctions": [ - 3035 - ], + "baseFunctions": [3035], "body": { "id": 2628, "nodeType": "Block", @@ -1686,9 +1663,7 @@ "visibility": "public" }, { - "baseFunctions": [ - 3045 - ], + "baseFunctions": [3045], "body": { "id": 2646, "nodeType": "Block", @@ -1895,9 +1870,7 @@ "visibility": "public" }, { - "baseFunctions": [ - 3055 - ], + "baseFunctions": [3055], "body": { "id": 2667, "nodeType": "Block", @@ -2161,9 +2134,7 @@ "visibility": "public" }, { - "baseFunctions": [ - 3067 - ], + "baseFunctions": [3067], "body": { "id": 2705, "nodeType": "Block", @@ -3620,10 +3591,7 @@ "id": 2773, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "7128:7:5", "typeDescriptions": { @@ -3785,10 +3753,7 @@ "id": 2783, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "7208:7:5", "typeDescriptions": { @@ -4582,10 +4547,7 @@ "id": 2837, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "7907:7:5", "typeDescriptions": { @@ -5380,10 +5342,7 @@ "id": 2892, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "8597:7:5", "typeDescriptions": { @@ -6200,10 +6159,7 @@ "id": 2950, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "9448:7:5", "typeDescriptions": { @@ -6365,10 +6321,7 @@ "id": 2960, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "9526:7:5", "typeDescriptions": { @@ -6954,24 +6907,14 @@ "attributes": { "absolutePath": "@openzeppelin/contracts/token/ERC20/ERC20.sol", "exportedSymbols": { - "ERC20": [ - 3008 - ] + "ERC20": [3008] }, "license": "MIT" }, "children": [ { "attributes": { - "literals": [ - "solidity", - ">=", - "0.6", - ".0", - "<", - "0.8", - ".0" - ] + "literals": ["solidity", ">=", "0.6", ".0", "<", "0.8", ".0"] }, "id": 2507, "name": "PragmaDirective", @@ -6983,9 +6926,7 @@ "absolutePath": "@openzeppelin/contracts/utils/Context.sol", "file": "../../utils/Context.sol", "scope": 3009, - "symbolAliases": [ - null - ], + "symbolAliases": [null], "unitAlias": "" }, "id": 2508, @@ -6998,9 +6939,7 @@ "absolutePath": "@openzeppelin/contracts/token/ERC20/IERC20.sol", "file": "./IERC20.sol", "scope": 3009, - "symbolAliases": [ - null - ], + "symbolAliases": [null], "unitAlias": "" }, "id": 2509, @@ -7013,9 +6952,7 @@ "absolutePath": "@openzeppelin/contracts/math/SafeMath.sol", "file": "../../math/SafeMath.sol", "scope": 3009, - "symbolAliases": [ - null - ], + "symbolAliases": [null], "unitAlias": "" }, "id": 2510, @@ -7025,17 +6962,10 @@ { "attributes": { "abstract": false, - "contractDependencies": [ - 3086, - 3618 - ], + "contractDependencies": [3086, 3618], "contractKind": "contract", "fullyImplemented": true, - "linearizedBaseContracts": [ - 3008, - 3086, - 3618 - ], + "linearizedBaseContracts": [3008, 3086, 3618], "name": "ERC20", "scope": 3009 }, @@ -7347,9 +7277,7 @@ "implemented": true, "isConstructor": true, "kind": "constructor", - "modifiers": [ - null - ], + "modifiers": [null], "name": "", "overrides": null, "scope": 3008, @@ -7431,9 +7359,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 2543, @@ -7458,9 +7384,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2532, "type": "string storage ref", "value": "_name" @@ -7472,9 +7396,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2539, "type": "string memory", "value": "name_" @@ -7509,9 +7431,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2534, "type": "string storage ref", "value": "_symbol" @@ -7523,9 +7443,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2541, "type": "string memory", "value": "symbol_" @@ -7560,9 +7478,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2536, "type": "uint8", "value": "_decimals" @@ -7614,9 +7530,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "name", "overrides": null, "scope": 3008, @@ -7635,9 +7549,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 2559, @@ -7689,9 +7601,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2532, "type": "string storage ref", "value": "_name" @@ -7721,9 +7631,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "symbol", "overrides": null, "scope": 3008, @@ -7742,9 +7650,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 2568, @@ -7796,9 +7702,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2534, "type": "string storage ref", "value": "_symbol" @@ -7828,9 +7732,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "decimals", "overrides": null, "scope": 3008, @@ -7849,9 +7751,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 2577, @@ -7903,9 +7803,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2536, "type": "uint8", "value": "_decimals" @@ -7931,16 +7829,12 @@ }, { "attributes": { - "baseFunctions": [ - 3017 - ], + "baseFunctions": [3017], "functionSelector": "18160ddd", "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "totalSupply", "scope": 3008, "stateMutability": "view", @@ -7958,9 +7852,7 @@ }, { "attributes": { - "overrides": [ - null - ] + "overrides": [null] }, "id": 2587, "name": "OverrideSpecifier", @@ -7968,9 +7860,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 2586, @@ -8022,9 +7912,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2530, "type": "uint256", "value": "_totalSupply" @@ -8050,16 +7938,12 @@ }, { "attributes": { - "baseFunctions": [ - 3025 - ], + "baseFunctions": [3025], "functionSelector": "70a08231", "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "balanceOf", "scope": 3008, "stateMutability": "view", @@ -8077,9 +7961,7 @@ }, { "attributes": { - "overrides": [ - null - ] + "overrides": [null] }, "id": 2599, "name": "OverrideSpecifier", @@ -8176,9 +8058,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2522, "type": "mapping(address => uint256)", "value": "_balances" @@ -8190,9 +8070,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2597, "type": "address", "value": "account" @@ -8223,16 +8101,12 @@ }, { "attributes": { - "baseFunctions": [ - 3035 - ], + "baseFunctions": [3035], "functionSelector": "a9059cbb", "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "transfer", "scope": 3008, "stateMutability": "nonpayable", @@ -8250,9 +8124,7 @@ }, { "attributes": { - "overrides": [ - null - ] + "overrides": [null] }, "id": 2615, "name": "OverrideSpecifier", @@ -8369,9 +8241,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -8393,9 +8263,7 @@ "typeString": "uint256" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2829, "type": "function (address,address,uint256)", "value": "_transfer" @@ -8407,17 +8275,13 @@ { "attributes": { "argumentTypes": null, - "arguments": [ - null - ], + "arguments": [null], "isConstant": false, "isLValue": false, "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": false @@ -8425,12 +8289,8 @@ "children": [ { "attributes": { - "argumentTypes": [ - null - ], - "overloadedDeclarations": [ - null - ], + "argumentTypes": [null], + "overloadedDeclarations": [null], "referencedDeclaration": 3606, "type": "function () view returns (address payable)", "value": "_msgSender" @@ -8447,9 +8307,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2611, "type": "address", "value": "recipient" @@ -8461,9 +8319,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2613, "type": "uint256", "value": "amount" @@ -8521,16 +8377,12 @@ }, { "attributes": { - "baseFunctions": [ - 3045 - ], + "baseFunctions": [3045], "functionSelector": "dd62ed3e", "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "allowance", "scope": 3008, "stateMutability": "view", @@ -8548,9 +8400,7 @@ }, { "attributes": { - "overrides": [ - null - ] + "overrides": [null] }, "id": 2636, "name": "OverrideSpecifier", @@ -8686,9 +8536,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2528, "type": "mapping(address => mapping(address => uint256))", "value": "_allowances" @@ -8700,9 +8548,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2632, "type": "address", "value": "owner" @@ -8719,9 +8565,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2634, "type": "address", "value": "spender" @@ -8752,16 +8596,12 @@ }, { "attributes": { - "baseFunctions": [ - 3055 - ], + "baseFunctions": [3055], "functionSelector": "095ea7b3", "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "approve", "scope": 3008, "stateMutability": "nonpayable", @@ -8779,9 +8619,7 @@ }, { "attributes": { - "overrides": [ - null - ] + "overrides": [null] }, "id": 2654, "name": "OverrideSpecifier", @@ -8898,9 +8736,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -8922,9 +8758,7 @@ "typeString": "uint256" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2985, "type": "function (address,address,uint256)", "value": "_approve" @@ -8936,17 +8770,13 @@ { "attributes": { "argumentTypes": null, - "arguments": [ - null - ], + "arguments": [null], "isConstant": false, "isLValue": false, "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": false @@ -8954,12 +8784,8 @@ "children": [ { "attributes": { - "argumentTypes": [ - null - ], - "overloadedDeclarations": [ - null - ], + "argumentTypes": [null], + "overloadedDeclarations": [null], "referencedDeclaration": 3606, "type": "function () view returns (address payable)", "value": "_msgSender" @@ -8976,9 +8802,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2650, "type": "address", "value": "spender" @@ -8990,9 +8814,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2652, "type": "uint256", "value": "amount" @@ -9050,16 +8872,12 @@ }, { "attributes": { - "baseFunctions": [ - 3067 - ], + "baseFunctions": [3067], "functionSelector": "23b872dd", "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "transferFrom", "scope": 3008, "stateMutability": "nonpayable", @@ -9077,9 +8895,7 @@ }, { "attributes": { - "overrides": [ - null - ] + "overrides": [null] }, "id": 2677, "name": "OverrideSpecifier", @@ -9225,9 +9041,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -9249,9 +9063,7 @@ "typeString": "uint256" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2829, "type": "function (address,address,uint256)", "value": "_transfer" @@ -9263,9 +9075,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2671, "type": "address", "value": "sender" @@ -9277,9 +9087,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2673, "type": "address", "value": "recipient" @@ -9291,9 +9099,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2675, "type": "uint256", "value": "amount" @@ -9322,9 +9128,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -9346,9 +9150,7 @@ "typeString": "uint256" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2985, "type": "function (address,address,uint256)", "value": "_approve" @@ -9360,9 +9162,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2671, "type": "address", "value": "sender" @@ -9374,17 +9174,13 @@ { "attributes": { "argumentTypes": null, - "arguments": [ - null - ], + "arguments": [null], "isConstant": false, "isLValue": false, "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": false @@ -9392,12 +9188,8 @@ "children": [ { "attributes": { - "argumentTypes": [ - null - ], - "overloadedDeclarations": [ - null - ], + "argumentTypes": [null], + "overloadedDeclarations": [null], "referencedDeclaration": 3606, "type": "function () view returns (address payable)", "value": "_msgSender" @@ -9419,9 +9211,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -9471,9 +9261,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2528, "type": "mapping(address => mapping(address => uint256))", "value": "_allowances" @@ -9485,9 +9273,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2671, "type": "address", "value": "sender" @@ -9504,17 +9290,13 @@ { "attributes": { "argumentTypes": null, - "arguments": [ - null - ], + "arguments": [null], "isConstant": false, "isLValue": false, "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": false @@ -9522,12 +9304,8 @@ "children": [ { "attributes": { - "argumentTypes": [ - null - ], - "overloadedDeclarations": [ - null - ], + "argumentTypes": [null], + "overloadedDeclarations": [null], "referencedDeclaration": 3606, "type": "function () view returns (address payable)", "value": "_msgSender" @@ -9554,9 +9332,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2675, "type": "uint256", "value": "amount" @@ -9640,9 +9416,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "increaseAllowance", "overrides": null, "scope": 3008, @@ -9770,9 +9544,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -9794,9 +9566,7 @@ "typeString": "uint256" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2985, "type": "function (address,address,uint256)", "value": "_approve" @@ -9808,17 +9578,13 @@ { "attributes": { "argumentTypes": null, - "arguments": [ - null - ], + "arguments": [null], "isConstant": false, "isLValue": false, "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": false @@ -9826,12 +9592,8 @@ "children": [ { "attributes": { - "argumentTypes": [ - null - ], - "overloadedDeclarations": [ - null - ], + "argumentTypes": [null], + "overloadedDeclarations": [null], "referencedDeclaration": 3606, "type": "function () view returns (address payable)", "value": "_msgSender" @@ -9848,9 +9610,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2709, "type": "address", "value": "spender" @@ -9867,9 +9627,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -9915,9 +9673,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2528, "type": "mapping(address => mapping(address => uint256))", "value": "_allowances" @@ -9929,17 +9685,13 @@ { "attributes": { "argumentTypes": null, - "arguments": [ - null - ], + "arguments": [null], "isConstant": false, "isLValue": false, "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": false @@ -9947,9 +9699,7 @@ "children": [ { "attributes": { - "argumentTypes": [ - null - ], + "argumentTypes": [null], "overloadedDeclarations": [ null ], @@ -9974,9 +9724,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2709, "type": "address", "value": "spender" @@ -9998,9 +9746,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2711, "type": "uint256", "value": "addedValue" @@ -10067,9 +9813,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "decreaseAllowance", "overrides": null, "scope": 3008, @@ -10197,9 +9941,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -10221,9 +9963,7 @@ "typeString": "uint256" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2985, "type": "function (address,address,uint256)", "value": "_approve" @@ -10235,17 +9975,13 @@ { "attributes": { "argumentTypes": null, - "arguments": [ - null - ], + "arguments": [null], "isConstant": false, "isLValue": false, "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": false @@ -10253,12 +9989,8 @@ "children": [ { "attributes": { - "argumentTypes": [ - null - ], - "overloadedDeclarations": [ - null - ], + "argumentTypes": [null], + "overloadedDeclarations": [null], "referencedDeclaration": 3606, "type": "function () view returns (address payable)", "value": "_msgSender" @@ -10275,9 +10007,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2737, "type": "address", "value": "spender" @@ -10294,9 +10024,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -10346,9 +10074,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2528, "type": "mapping(address => mapping(address => uint256))", "value": "_allowances" @@ -10360,17 +10086,13 @@ { "attributes": { "argumentTypes": null, - "arguments": [ - null - ], + "arguments": [null], "isConstant": false, "isLValue": false, "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": false @@ -10378,9 +10100,7 @@ "children": [ { "attributes": { - "argumentTypes": [ - null - ], + "argumentTypes": [null], "overloadedDeclarations": [ null ], @@ -10405,9 +10125,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2737, "type": "address", "value": "spender" @@ -10429,9 +10147,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2739, "type": "uint256", "value": "subtractedValue" @@ -10514,9 +10230,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "_transfer", "overrides": null, "scope": 3008, @@ -10628,9 +10342,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 2772, @@ -10649,9 +10361,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -10669,10 +10379,7 @@ "typeString": "literal_string \"ERC20: transfer from the zero address\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -10699,9 +10406,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2766, "type": "address", "value": "sender" @@ -10718,9 +10423,7 @@ "isPure": true, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": true @@ -10819,9 +10522,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -10839,10 +10540,7 @@ "typeString": "literal_string \"ERC20: transfer to the zero address\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -10869,9 +10567,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2768, "type": "address", "value": "recipient" @@ -10888,9 +10584,7 @@ "isPure": true, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": true @@ -10989,9 +10683,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -11013,9 +10705,7 @@ "typeString": "uint256" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3007, "type": "function (address,address,uint256)", "value": "_beforeTokenTransfer" @@ -11027,9 +10717,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2766, "type": "address", "value": "sender" @@ -11041,9 +10729,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2768, "type": "address", "value": "recipient" @@ -11055,9 +10741,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2770, "type": "uint256", "value": "amount" @@ -11102,9 +10786,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2522, "type": "mapping(address => uint256)", "value": "_balances" @@ -11116,9 +10798,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2766, "type": "address", "value": "sender" @@ -11140,9 +10820,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -11182,9 +10860,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2522, "type": "mapping(address => uint256)", "value": "_balances" @@ -11196,9 +10872,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2766, "type": "address", "value": "sender" @@ -11220,9 +10894,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2770, "type": "uint256", "value": "amount" @@ -11289,9 +10961,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2522, "type": "mapping(address => uint256)", "value": "_balances" @@ -11303,9 +10973,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2768, "type": "address", "value": "recipient" @@ -11327,9 +10995,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -11365,9 +11031,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2522, "type": "mapping(address => uint256)", "value": "_balances" @@ -11379,9 +11043,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2768, "type": "address", "value": "recipient" @@ -11403,9 +11065,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2770, "type": "uint256", "value": "amount" @@ -11439,9 +11099,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -11463,9 +11121,7 @@ "typeString": "uint256" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3076, "type": "function (address,address,uint256)", "value": "Transfer" @@ -11477,9 +11133,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2766, "type": "address", "value": "sender" @@ -11491,9 +11145,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2768, "type": "address", "value": "recipient" @@ -11505,9 +11157,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2770, "type": "uint256", "value": "amount" @@ -11541,9 +11191,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "_mint", "overrides": null, "scope": 3008, @@ -11626,9 +11274,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 2836, @@ -11647,9 +11293,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -11667,10 +11311,7 @@ "typeString": "literal_string \"ERC20: mint to the zero address\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -11697,9 +11338,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2832, "type": "address", "value": "account" @@ -11716,9 +11355,7 @@ "isPure": true, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": true @@ -11817,9 +11454,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -11841,9 +11476,7 @@ "typeString": "uint256" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3007, "type": "function (address,address,uint256)", "value": "_beforeTokenTransfer" @@ -11860,9 +11493,7 @@ "isPure": true, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": true @@ -11922,9 +11553,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2832, "type": "address", "value": "account" @@ -11936,9 +11565,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2834, "type": "uint256", "value": "amount" @@ -11973,9 +11600,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2530, "type": "uint256", "value": "_totalSupply" @@ -11992,9 +11617,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -12020,9 +11643,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2530, "type": "uint256", "value": "_totalSupply" @@ -12039,9 +11660,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2834, "type": "uint256", "value": "amount" @@ -12091,9 +11710,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2522, "type": "mapping(address => uint256)", "value": "_balances" @@ -12105,9 +11722,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2832, "type": "address", "value": "account" @@ -12129,9 +11744,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -12167,9 +11780,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2522, "type": "mapping(address => uint256)", "value": "_balances" @@ -12181,9 +11792,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2832, "type": "address", "value": "account" @@ -12205,9 +11814,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2834, "type": "uint256", "value": "amount" @@ -12241,9 +11848,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -12265,9 +11870,7 @@ "typeString": "uint256" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3076, "type": "function (address,address,uint256)", "value": "Transfer" @@ -12284,9 +11887,7 @@ "isPure": true, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": true @@ -12346,9 +11947,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2832, "type": "address", "value": "account" @@ -12360,9 +11959,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2834, "type": "uint256", "value": "amount" @@ -12396,9 +11993,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "_burn", "overrides": null, "scope": 3008, @@ -12481,9 +12076,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 2891, @@ -12502,9 +12095,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -12522,10 +12113,7 @@ "typeString": "literal_string \"ERC20: burn from the zero address\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -12552,9 +12140,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2887, "type": "address", "value": "account" @@ -12571,9 +12157,7 @@ "isPure": true, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": true @@ -12672,9 +12256,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -12696,9 +12278,7 @@ "typeString": "uint256" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3007, "type": "function (address,address,uint256)", "value": "_beforeTokenTransfer" @@ -12710,9 +12290,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2887, "type": "address", "value": "account" @@ -12729,9 +12307,7 @@ "isPure": true, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": true @@ -12791,9 +12367,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2889, "type": "uint256", "value": "amount" @@ -12838,9 +12412,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2522, "type": "mapping(address => uint256)", "value": "_balances" @@ -12852,9 +12424,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2887, "type": "address", "value": "account" @@ -12876,9 +12446,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -12918,9 +12486,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2522, "type": "mapping(address => uint256)", "value": "_balances" @@ -12932,9 +12498,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2887, "type": "address", "value": "account" @@ -12956,9 +12520,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2889, "type": "uint256", "value": "amount" @@ -13015,9 +12577,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2530, "type": "uint256", "value": "_totalSupply" @@ -13034,9 +12594,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -13062,9 +12620,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2530, "type": "uint256", "value": "_totalSupply" @@ -13081,9 +12637,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2889, "type": "uint256", "value": "amount" @@ -13117,9 +12671,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -13141,9 +12693,7 @@ "typeString": "uint256" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3076, "type": "function (address,address,uint256)", "value": "Transfer" @@ -13155,9 +12705,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2887, "type": "address", "value": "account" @@ -13174,9 +12722,7 @@ "isPure": true, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": true @@ -13236,9 +12782,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2889, "type": "uint256", "value": "amount" @@ -13272,9 +12816,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "_approve", "overrides": null, "scope": 3008, @@ -13386,9 +12928,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 2949, @@ -13407,9 +12947,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -13427,10 +12965,7 @@ "typeString": "literal_string \"ERC20: approve from the zero address\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -13457,9 +12992,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2943, "type": "address", "value": "owner" @@ -13476,9 +13009,7 @@ "isPure": true, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": true @@ -13577,9 +13108,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -13597,10 +13126,7 @@ "typeString": "literal_string \"ERC20: approve to the zero address\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -13627,9 +13153,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2945, "type": "address", "value": "spender" @@ -13646,9 +13170,7 @@ "isPure": true, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": true @@ -13773,9 +13295,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2528, "type": "mapping(address => mapping(address => uint256))", "value": "_allowances" @@ -13787,9 +13307,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2943, "type": "address", "value": "owner" @@ -13806,9 +13324,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2945, "type": "address", "value": "spender" @@ -13825,9 +13341,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2947, "type": "uint256", "value": "amount" @@ -13856,9 +13370,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -13880,9 +13392,7 @@ "typeString": "uint256" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3085, "type": "function (address,address,uint256)", "value": "Approval" @@ -13894,9 +13404,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2943, "type": "address", "value": "owner" @@ -13908,9 +13416,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2945, "type": "address", "value": "spender" @@ -13922,9 +13428,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2947, "type": "uint256", "value": "amount" @@ -13958,9 +13462,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "_setupDecimals", "overrides": null, "scope": 3008, @@ -14014,9 +13516,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 2990, @@ -14041,9 +13541,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2536, "type": "uint8", "value": "_decimals" @@ -14055,9 +13553,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2988, "type": "uint8", "value": "decimals_" @@ -14091,9 +13587,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "_beforeTokenTransfer", "overrides": null, "scope": 3008, @@ -14205,9 +13699,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 3005, @@ -14216,9 +13708,7 @@ }, { "attributes": { - "statements": [ - null - ] + "statements": [null] }, "children": [], "id": 3006, @@ -14295,4 +13785,4 @@ "methods": {}, "version": 1 } -} \ No newline at end of file +} diff --git a/packages/bridge/contracts/IERC20.json b/packages/bridge-sdk/contracts/IERC20.json similarity index 98% rename from packages/bridge/contracts/IERC20.json rename to packages/bridge-sdk/contracts/IERC20.json index 1a967e6..34af045 100644 --- a/packages/bridge/contracts/IERC20.json +++ b/packages/bridge-sdk/contracts/IERC20.json @@ -196,9 +196,7 @@ "ast": { "absolutePath": "@openzeppelin/contracts/token/ERC20/IERC20.sol", "exportedSymbols": { - "IERC20": [ - 3086 - ] + "IERC20": [3086] }, "id": 3087, "license": "MIT", @@ -206,15 +204,7 @@ "nodes": [ { "id": 3010, - "literals": [ - "solidity", - ">=", - "0.6", - ".0", - "<", - "0.8", - ".0" - ], + "literals": ["solidity", ">=", "0.6", ".0", "<", "0.8", ".0"], "nodeType": "PragmaDirective", "src": "33:31:6" }, @@ -231,9 +221,7 @@ }, "fullyImplemented": false, "id": 3086, - "linearizedBaseContracts": [ - 3086 - ], + "linearizedBaseContracts": [3086], "name": "IERC20", "nodeType": "ContractDefinition", "nodes": [ @@ -1136,24 +1124,14 @@ "attributes": { "absolutePath": "@openzeppelin/contracts/token/ERC20/IERC20.sol", "exportedSymbols": { - "IERC20": [ - 3086 - ] + "IERC20": [3086] }, "license": "MIT" }, "children": [ { "attributes": { - "literals": [ - "solidity", - ">=", - "0.6", - ".0", - "<", - "0.8", - ".0" - ] + "literals": ["solidity", ">=", "0.6", ".0", "<", "0.8", ".0"] }, "id": 3010, "name": "PragmaDirective", @@ -1162,17 +1140,11 @@ { "attributes": { "abstract": false, - "baseContracts": [ - null - ], - "contractDependencies": [ - null - ], + "baseContracts": [null], + "contractDependencies": [null], "contractKind": "interface", "fullyImplemented": false, - "linearizedBaseContracts": [ - 3086 - ], + "linearizedBaseContracts": [3086], "name": "IERC20", "scope": 3087 }, @@ -1192,9 +1164,7 @@ "implemented": false, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "totalSupply", "overrides": null, "scope": 3086, @@ -1213,9 +1183,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 3013, @@ -1269,9 +1237,7 @@ "implemented": false, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "balanceOf", "overrides": null, "scope": 3086, @@ -1371,9 +1337,7 @@ "implemented": false, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "transfer", "overrides": null, "scope": 3086, @@ -1501,9 +1465,7 @@ "implemented": false, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "allowance", "overrides": null, "scope": 3086, @@ -1632,9 +1594,7 @@ "implemented": false, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "approve", "overrides": null, "scope": 3086, @@ -1762,9 +1722,7 @@ "implemented": false, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "transferFrom", "overrides": null, "scope": 3086, @@ -2199,4 +2157,4 @@ "methods": {}, "version": 1 } -} \ No newline at end of file +} diff --git a/packages/bridge/contracts/ReentrancyGuard.json b/packages/bridge-sdk/contracts/ReentrancyGuard.json similarity index 94% rename from packages/bridge/contracts/ReentrancyGuard.json rename to packages/bridge-sdk/contracts/ReentrancyGuard.json index fba33b9..6d868b3 100644 --- a/packages/bridge/contracts/ReentrancyGuard.json +++ b/packages/bridge-sdk/contracts/ReentrancyGuard.json @@ -12,9 +12,7 @@ "ast": { "absolutePath": "@openzeppelin/contracts/utils/ReentrancyGuard.sol", "exportedSymbols": { - "ReentrancyGuard": [ - 3658 - ] + "ReentrancyGuard": [3658] }, "id": 3659, "license": "MIT", @@ -22,15 +20,7 @@ "nodes": [ { "id": 3620, - "literals": [ - "solidity", - ">=", - "0.6", - ".0", - "<", - "0.8", - ".0" - ], + "literals": ["solidity", ">=", "0.6", ".0", "<", "0.8", ".0"], "nodeType": "PragmaDirective", "src": "33:31:10" }, @@ -47,9 +37,7 @@ }, "fullyImplemented": true, "id": 3658, - "linearizedBaseContracts": [ - 3658 - ], + "linearizedBaseContracts": [3658], "name": "ReentrancyGuard", "nodeType": "ContractDefinition", "nodes": [ @@ -339,10 +327,7 @@ "id": 3640, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "2269:7:10", "typeDescriptions": { @@ -499,24 +484,14 @@ "attributes": { "absolutePath": "@openzeppelin/contracts/utils/ReentrancyGuard.sol", "exportedSymbols": { - "ReentrancyGuard": [ - 3658 - ] + "ReentrancyGuard": [3658] }, "license": "MIT" }, "children": [ { "attributes": { - "literals": [ - "solidity", - ">=", - "0.6", - ".0", - "<", - "0.8", - ".0" - ] + "literals": ["solidity", ">=", "0.6", ".0", "<", "0.8", ".0"] }, "id": 3620, "name": "PragmaDirective", @@ -525,17 +500,11 @@ { "attributes": { "abstract": true, - "baseContracts": [ - null - ], - "contractDependencies": [ - null - ], + "baseContracts": [null], + "contractDependencies": [null], "contractKind": "contract", "fullyImplemented": true, - "linearizedBaseContracts": [ - 3658 - ], + "linearizedBaseContracts": [3658], "name": "ReentrancyGuard", "scope": 3659 }, @@ -670,9 +639,7 @@ "implemented": true, "isConstructor": true, "kind": "constructor", - "modifiers": [ - null - ], + "modifiers": [null], "name": "", "overrides": null, "scope": 3658, @@ -683,9 +650,7 @@ "children": [ { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 3630, @@ -694,9 +659,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 3631, @@ -721,9 +684,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3629, "type": "uint256", "value": "_status" @@ -735,9 +696,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3624, "type": "uint256", "value": "_NOT_ENTERED" @@ -784,9 +743,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 3639, @@ -805,9 +762,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -825,10 +780,7 @@ "typeString": "literal_string \"ReentrancyGuard: reentrant call\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -855,9 +807,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3629, "type": "uint256", "value": "_status" @@ -869,9 +819,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3627, "type": "uint256", "value": "_ENTERED" @@ -928,9 +876,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3629, "type": "uint256", "value": "_status" @@ -942,9 +888,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3627, "type": "uint256", "value": "_ENTERED" @@ -984,9 +928,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3629, "type": "uint256", "value": "_status" @@ -998,9 +940,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3624, "type": "uint256", "value": "_NOT_ENTERED" @@ -1057,4 +997,4 @@ "methods": {}, "version": 1 } -} \ No newline at end of file +} diff --git a/packages/bridge/contracts/SafeERC20.json b/packages/bridge-sdk/contracts/SafeERC20.json similarity index 96% rename from packages/bridge/contracts/SafeERC20.json rename to packages/bridge-sdk/contracts/SafeERC20.json index 001a596..e984cbc 100644 --- a/packages/bridge/contracts/SafeERC20.json +++ b/packages/bridge-sdk/contracts/SafeERC20.json @@ -12,9 +12,7 @@ "ast": { "absolutePath": "@openzeppelin/contracts/token/ERC20/SafeERC20.sol", "exportedSymbols": { - "SafeERC20": [ - 3299 - ] + "SafeERC20": [3299] }, "id": 3300, "license": "MIT", @@ -22,15 +20,7 @@ "nodes": [ { "id": 3088, - "literals": [ - "solidity", - ">=", - "0.6", - ".0", - "<", - "0.8", - ".0" - ], + "literals": ["solidity", ">=", "0.6", ".0", "<", "0.8", ".0"], "nodeType": "PragmaDirective", "src": "33:31:7" }, @@ -80,9 +70,7 @@ }, "fullyImplemented": true, "id": 3299, - "linearizedBaseContracts": [ - 3299 - ], + "linearizedBaseContracts": [3299], "name": "SafeERC20", "nodeType": "ContractDefinition", "nodes": [ @@ -1127,10 +1115,7 @@ "id": 3155, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "1704:7:7", "typeDescriptions": { @@ -1476,9 +1461,7 @@ "src": "2053:197:7", "statements": [ { - "assignments": [ - 3198 - ], + "assignments": [3198], "declarations": [ { "constant": false, @@ -2011,9 +1994,7 @@ "src": "2342:242:7", "statements": [ { - "assignments": [ - 3234 - ], + "assignments": [3234], "declarations": [ { "constant": false, @@ -2568,9 +2549,7 @@ "src": "3037:681:7", "statements": [ { - "assignments": [ - 3270 - ], + "assignments": [3270], "declarations": [ { "constant": false, @@ -2965,10 +2944,7 @@ "id": 3284, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "3616:7:7", "typeDescriptions": { @@ -3101,24 +3077,14 @@ "attributes": { "absolutePath": "@openzeppelin/contracts/token/ERC20/SafeERC20.sol", "exportedSymbols": { - "SafeERC20": [ - 3299 - ] + "SafeERC20": [3299] }, "license": "MIT" }, "children": [ { "attributes": { - "literals": [ - "solidity", - ">=", - "0.6", - ".0", - "<", - "0.8", - ".0" - ] + "literals": ["solidity", ">=", "0.6", ".0", "<", "0.8", ".0"] }, "id": 3088, "name": "PragmaDirective", @@ -3130,9 +3096,7 @@ "absolutePath": "@openzeppelin/contracts/token/ERC20/IERC20.sol", "file": "./IERC20.sol", "scope": 3300, - "symbolAliases": [ - null - ], + "symbolAliases": [null], "unitAlias": "" }, "id": 3089, @@ -3145,9 +3109,7 @@ "absolutePath": "@openzeppelin/contracts/math/SafeMath.sol", "file": "../../math/SafeMath.sol", "scope": 3300, - "symbolAliases": [ - null - ], + "symbolAliases": [null], "unitAlias": "" }, "id": 3090, @@ -3160,9 +3122,7 @@ "absolutePath": "@openzeppelin/contracts/utils/Address.sol", "file": "../../utils/Address.sol", "scope": 3300, - "symbolAliases": [ - null - ], + "symbolAliases": [null], "unitAlias": "" }, "id": 3091, @@ -3172,17 +3132,11 @@ { "attributes": { "abstract": false, - "baseContracts": [ - null - ], - "contractDependencies": [ - null - ], + "baseContracts": [null], + "contractDependencies": [null], "contractKind": "library", "fullyImplemented": true, - "linearizedBaseContracts": [ - 3299 - ], + "linearizedBaseContracts": [3299], "name": "SafeERC20", "scope": 3300 }, @@ -3256,9 +3210,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "safeTransfer", "overrides": null, "scope": 3299, @@ -3363,9 +3315,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 3106, @@ -3384,9 +3334,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -3404,9 +3352,7 @@ "typeString": "bytes memory" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3298, "type": "function (contract IERC20,bytes memory)", "value": "_callOptionalReturn" @@ -3418,9 +3364,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3100, "type": "contract IERC20", "value": "token" @@ -3437,9 +3381,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes memory", "type_conversion": false @@ -3473,9 +3415,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -1, "type": "abi", "value": "abi" @@ -3516,9 +3456,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3100, "type": "contract IERC20", "value": "token" @@ -3540,9 +3478,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3102, "type": "address", "value": "to" @@ -3554,9 +3490,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3104, "type": "uint256", "value": "value" @@ -3596,9 +3530,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "safeTransferFrom", "overrides": null, "scope": 3299, @@ -3732,9 +3664,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 3130, @@ -3753,9 +3683,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -3773,9 +3701,7 @@ "typeString": "bytes memory" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3298, "type": "function (contract IERC20,bytes memory)", "value": "_callOptionalReturn" @@ -3787,9 +3713,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3122, "type": "contract IERC20", "value": "token" @@ -3806,9 +3730,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes memory", "type_conversion": false @@ -3846,9 +3768,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -1, "type": "abi", "value": "abi" @@ -3889,9 +3809,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3122, "type": "contract IERC20", "value": "token" @@ -3913,9 +3831,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3124, "type": "address", "value": "from" @@ -3927,9 +3843,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3126, "type": "address", "value": "to" @@ -3941,9 +3855,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3128, "type": "uint256", "value": "value" @@ -3982,9 +3894,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "safeApprove", "overrides": null, "scope": 3299, @@ -4097,9 +4007,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 3154, @@ -4118,9 +4026,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -4138,10 +4044,7 @@ "typeString": "literal_string \"SafeERC20: approve from non-zero to non-zero allowance\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -4194,9 +4097,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3152, "type": "uint256", "value": "value" @@ -4266,9 +4167,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -4322,9 +4221,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address", "type_conversion": true @@ -4381,9 +4278,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3150, "type": "address", "value": "spender" @@ -4466,9 +4361,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -4486,9 +4379,7 @@ "typeString": "bytes memory" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3298, "type": "function (contract IERC20,bytes memory)", "value": "_callOptionalReturn" @@ -4500,9 +4391,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3148, "type": "contract IERC20", "value": "token" @@ -4519,9 +4408,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes memory", "type_conversion": false @@ -4555,9 +4442,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -1, "type": "abi", "value": "abi" @@ -4598,9 +4483,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3148, "type": "contract IERC20", "value": "token" @@ -4622,9 +4505,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3150, "type": "address", "value": "spender" @@ -4636,9 +4517,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3152, "type": "uint256", "value": "value" @@ -4678,9 +4557,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "safeIncreaseAllowance", "overrides": null, "scope": 3299, @@ -4785,9 +4662,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 3196, @@ -4798,9 +4673,7 @@ "children": [ { "attributes": { - "assignments": [ - 3198 - ] + "assignments": [3198] }, "children": [ { @@ -4839,9 +4712,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -4872,9 +4743,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -4904,9 +4773,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3190, "type": "contract IERC20", "value": "token" @@ -4928,9 +4795,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address", "type_conversion": true @@ -4968,9 +4833,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -28, "type": "library SafeERC20", "value": "this" @@ -4987,9 +4850,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3192, "type": "address", "value": "spender" @@ -5011,9 +4872,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3194, "type": "uint256", "value": "value" @@ -5042,9 +4901,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -5062,9 +4919,7 @@ "typeString": "bytes memory" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3298, "type": "function (contract IERC20,bytes memory)", "value": "_callOptionalReturn" @@ -5076,9 +4931,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3190, "type": "contract IERC20", "value": "token" @@ -5095,9 +4948,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes memory", "type_conversion": false @@ -5131,9 +4982,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -1, "type": "abi", "value": "abi" @@ -5174,9 +5023,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3190, "type": "contract IERC20", "value": "token" @@ -5198,9 +5045,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3192, "type": "address", "value": "spender" @@ -5212,9 +5057,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3198, "type": "uint256", "value": "newAllowance" @@ -5254,9 +5097,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "safeDecreaseAllowance", "overrides": null, "scope": 3299, @@ -5361,9 +5202,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 3232, @@ -5374,9 +5213,7 @@ "children": [ { "attributes": { - "assignments": [ - 3234 - ] + "assignments": [3234] }, "children": [ { @@ -5415,9 +5252,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -5452,9 +5287,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -5484,9 +5317,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3226, "type": "contract IERC20", "value": "token" @@ -5508,9 +5339,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address", "type_conversion": true @@ -5548,9 +5377,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -28, "type": "library SafeERC20", "value": "this" @@ -5567,9 +5394,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3228, "type": "address", "value": "spender" @@ -5591,9 +5416,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3230, "type": "uint256", "value": "value" @@ -5639,9 +5462,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -5659,9 +5480,7 @@ "typeString": "bytes memory" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3298, "type": "function (contract IERC20,bytes memory)", "value": "_callOptionalReturn" @@ -5673,9 +5492,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3226, "type": "contract IERC20", "value": "token" @@ -5692,9 +5509,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes memory", "type_conversion": false @@ -5728,9 +5543,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -1, "type": "abi", "value": "abi" @@ -5771,9 +5584,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3226, "type": "contract IERC20", "value": "token" @@ -5795,9 +5606,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3228, "type": "address", "value": "spender" @@ -5809,9 +5618,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3234, "type": "uint256", "value": "newAllowance" @@ -5850,9 +5657,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "_callOptionalReturn", "overrides": null, "scope": 3299, @@ -5936,9 +5741,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 3268, @@ -5949,9 +5752,7 @@ "children": [ { "attributes": { - "assignments": [ - 3270 - ] + "assignments": [3270] }, "children": [ { @@ -5990,9 +5791,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes memory", "type_conversion": false @@ -6027,9 +5826,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address", "type_conversion": true @@ -6067,9 +5864,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3264, "type": "contract IERC20", "value": "token" @@ -6091,9 +5886,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3266, "type": "bytes memory", "value": "data" @@ -6164,9 +5957,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3270, "type": "bytes memory", "value": "returndata" @@ -6214,9 +6005,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -6234,10 +6023,7 @@ "typeString": "literal_string \"SafeERC20: ERC20 operation did not succeed\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -6254,9 +6040,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bool", "type_conversion": false @@ -6286,9 +6070,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -1, "type": "abi", "value": "abi" @@ -6305,9 +6087,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3270, "type": "bytes memory", "value": "returndata" @@ -6437,4 +6217,4 @@ "methods": {}, "version": 1 } -} \ No newline at end of file +} diff --git a/packages/bridge/contracts/SafeMath.json b/packages/bridge-sdk/contracts/SafeMath.json similarity index 96% rename from packages/bridge/contracts/SafeMath.json rename to packages/bridge-sdk/contracts/SafeMath.json index 3bc472a..8a23589 100644 --- a/packages/bridge/contracts/SafeMath.json +++ b/packages/bridge-sdk/contracts/SafeMath.json @@ -12,9 +12,7 @@ "ast": { "absolutePath": "@openzeppelin/contracts/math/SafeMath.sol", "exportedSymbols": { - "SafeMath": [ - 2505 - ] + "SafeMath": [2505] }, "id": 2506, "license": "MIT", @@ -22,15 +20,7 @@ "nodes": [ { "id": 2152, - "literals": [ - "solidity", - ">=", - "0.6", - ".0", - "<", - "0.8", - ".0" - ], + "literals": ["solidity", ">=", "0.6", ".0", "<", "0.8", ".0"], "nodeType": "PragmaDirective", "src": "33:31:4" }, @@ -47,9 +37,7 @@ }, "fullyImplemented": true, "id": 2505, - "linearizedBaseContracts": [ - 2505 - ], + "linearizedBaseContracts": [2505], "name": "SafeMath", "nodeType": "ContractDefinition", "nodes": [ @@ -60,9 +48,7 @@ "src": "865:98:4", "statements": [ { - "assignments": [ - 2166 - ], + "assignments": [2166], "declarations": [ { "constant": false, @@ -924,9 +910,7 @@ } }, { - "assignments": [ - 2232 - ], + "assignments": [2232], "declarations": [ { "constant": false, @@ -2064,9 +2048,7 @@ "src": "2757:108:4", "statements": [ { - "assignments": [ - 2317 - ], + "assignments": [2317], "declarations": [ { "constant": false, @@ -2228,10 +2210,7 @@ "id": 2322, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "2794:7:4", "typeDescriptions": { @@ -2484,10 +2463,7 @@ "id": 2342, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "3213:7:4", "typeDescriptions": { @@ -2771,9 +2747,7 @@ } }, { - "assignments": [ - 2371 - ], + "assignments": [2371], "declarations": [ { "constant": false, @@ -2967,10 +2941,7 @@ "id": 2376, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "3672:7:4", "typeDescriptions": { @@ -3228,10 +3199,7 @@ "id": 2398, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "4294:7:4", "typeDescriptions": { @@ -3521,10 +3489,7 @@ "id": 2420, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "4897:7:4", "typeDescriptions": { @@ -3804,10 +3769,7 @@ "id": 2444, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "5537:7:4", "typeDescriptions": { @@ -4120,10 +4082,7 @@ "id": 2468, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "6357:7:4", "typeDescriptions": { @@ -4436,10 +4395,7 @@ "id": 2492, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "7165:7:4", "typeDescriptions": { @@ -4675,24 +4631,14 @@ "attributes": { "absolutePath": "@openzeppelin/contracts/math/SafeMath.sol", "exportedSymbols": { - "SafeMath": [ - 2505 - ] + "SafeMath": [2505] }, "license": "MIT" }, "children": [ { "attributes": { - "literals": [ - "solidity", - ">=", - "0.6", - ".0", - "<", - "0.8", - ".0" - ] + "literals": ["solidity", ">=", "0.6", ".0", "<", "0.8", ".0"] }, "id": 2152, "name": "PragmaDirective", @@ -4701,17 +4647,11 @@ { "attributes": { "abstract": false, - "baseContracts": [ - null - ], - "contractDependencies": [ - null - ], + "baseContracts": [null], + "contractDependencies": [null], "contractKind": "library", "fullyImplemented": true, - "linearizedBaseContracts": [ - 2505 - ], + "linearizedBaseContracts": [2505], "name": "SafeMath", "scope": 2506 }, @@ -4729,9 +4669,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "tryAdd", "overrides": null, "scope": 2505, @@ -4878,9 +4816,7 @@ "children": [ { "attributes": { - "assignments": [ - 2166 - ] + "assignments": [2166] }, "children": [ { @@ -4929,9 +4865,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2156, "type": "uint256", "value": "a" @@ -4943,9 +4877,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2158, "type": "uint256", "value": "b" @@ -4987,9 +4919,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2166, "type": "uint256", "value": "c" @@ -5001,9 +4931,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2156, "type": "uint256", "value": "a" @@ -5118,9 +5046,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2166, "type": "uint256", "value": "c" @@ -5154,9 +5080,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "trySub", "overrides": null, "scope": 2505, @@ -5324,9 +5248,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2189, "type": "uint256", "value": "b" @@ -5338,9 +5260,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2187, "type": "uint256", "value": "a" @@ -5470,9 +5390,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2187, "type": "uint256", "value": "a" @@ -5484,9 +5402,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2189, "type": "uint256", "value": "b" @@ -5525,9 +5441,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "tryMul", "overrides": null, "scope": 2505, @@ -5695,9 +5609,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2214, "type": "uint256", "value": "a" @@ -5795,9 +5707,7 @@ }, { "attributes": { - "assignments": [ - 2232 - ] + "assignments": [2232] }, "children": [ { @@ -5846,9 +5756,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2214, "type": "uint256", "value": "a" @@ -5860,9 +5768,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2216, "type": "uint256", "value": "b" @@ -5919,9 +5825,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2232, "type": "uint256", "value": "c" @@ -5933,9 +5837,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2214, "type": "uint256", "value": "a" @@ -5952,9 +5854,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2216, "type": "uint256", "value": "b" @@ -6069,9 +5969,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2232, "type": "uint256", "value": "c" @@ -6105,9 +6003,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "tryDiv", "overrides": null, "scope": 2505, @@ -6275,9 +6171,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2257, "type": "uint256", "value": "b" @@ -6424,9 +6318,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2255, "type": "uint256", "value": "a" @@ -6438,9 +6330,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2257, "type": "uint256", "value": "b" @@ -6479,9 +6369,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "tryMod", "overrides": null, "scope": 2505, @@ -6649,9 +6537,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2284, "type": "uint256", "value": "b" @@ -6798,9 +6684,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2282, "type": "uint256", "value": "a" @@ -6812,9 +6696,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2284, "type": "uint256", "value": "b" @@ -6853,9 +6735,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "add", "overrides": null, "scope": 2505, @@ -6974,9 +6854,7 @@ "children": [ { "attributes": { - "assignments": [ - 2317 - ] + "assignments": [2317] }, "children": [ { @@ -7025,9 +6903,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2309, "type": "uint256", "value": "a" @@ -7039,9 +6915,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2311, "type": "uint256", "value": "b" @@ -7070,9 +6944,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -7090,10 +6962,7 @@ "typeString": "literal_string \"SafeMath: addition overflow\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -7120,9 +6989,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2317, "type": "uint256", "value": "c" @@ -7134,9 +7001,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2309, "type": "uint256", "value": "a" @@ -7185,9 +7050,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2317, "type": "uint256", "value": "c" @@ -7216,9 +7079,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "sub", "overrides": null, "scope": 2505, @@ -7345,9 +7206,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -7365,10 +7224,7 @@ "typeString": "literal_string \"SafeMath: subtraction overflow\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -7395,9 +7251,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2337, "type": "uint256", "value": "b" @@ -7409,9 +7263,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2335, "type": "uint256", "value": "a" @@ -7475,9 +7327,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2335, "type": "uint256", "value": "a" @@ -7489,9 +7339,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2337, "type": "uint256", "value": "b" @@ -7525,9 +7373,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "mul", "overrides": null, "scope": 2505, @@ -7667,9 +7513,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2357, "type": "uint256", "value": "a" @@ -7734,9 +7578,7 @@ }, { "attributes": { - "assignments": [ - 2371 - ] + "assignments": [2371] }, "children": [ { @@ -7785,9 +7627,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2357, "type": "uint256", "value": "a" @@ -7799,9 +7639,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2359, "type": "uint256", "value": "b" @@ -7830,9 +7668,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -7850,10 +7686,7 @@ "typeString": "literal_string \"SafeMath: multiplication overflow\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -7895,9 +7728,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2371, "type": "uint256", "value": "c" @@ -7909,9 +7740,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2357, "type": "uint256", "value": "a" @@ -7928,9 +7757,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2359, "type": "uint256", "value": "b" @@ -7979,9 +7806,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2371, "type": "uint256", "value": "c" @@ -8010,9 +7835,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "div", "overrides": null, "scope": 2505, @@ -8139,9 +7962,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -8159,10 +7980,7 @@ "typeString": "literal_string \"SafeMath: division by zero\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -8189,9 +8007,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2393, "type": "uint256", "value": "b" @@ -8272,9 +8088,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2391, "type": "uint256", "value": "a" @@ -8286,9 +8100,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2393, "type": "uint256", "value": "b" @@ -8322,9 +8134,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "mod", "overrides": null, "scope": 2505, @@ -8451,9 +8261,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -8471,10 +8279,7 @@ "typeString": "literal_string \"SafeMath: modulo by zero\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -8501,9 +8306,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2415, "type": "uint256", "value": "b" @@ -8584,9 +8387,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2413, "type": "uint256", "value": "a" @@ -8598,9 +8399,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2415, "type": "uint256", "value": "b" @@ -8634,9 +8433,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "sub", "overrides": null, "scope": 2505, @@ -8791,9 +8588,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -8811,10 +8606,7 @@ "typeString": "string memory" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -8841,9 +8633,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2437, "type": "uint256", "value": "b" @@ -8855,9 +8645,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2435, "type": "uint256", "value": "a" @@ -8874,9 +8662,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2439, "type": "string memory", "value": "errorMessage" @@ -8918,9 +8704,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2435, "type": "uint256", "value": "a" @@ -8932,9 +8716,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2437, "type": "uint256", "value": "b" @@ -8968,9 +8750,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "div", "overrides": null, "scope": 2505, @@ -9125,9 +8905,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -9145,10 +8923,7 @@ "typeString": "string memory" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -9175,9 +8950,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2461, "type": "uint256", "value": "b" @@ -9211,9 +8984,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2463, "type": "string memory", "value": "errorMessage" @@ -9255,9 +9026,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2459, "type": "uint256", "value": "a" @@ -9269,9 +9038,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2461, "type": "uint256", "value": "b" @@ -9305,9 +9072,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "mod", "overrides": null, "scope": 2505, @@ -9462,9 +9227,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -9482,10 +9245,7 @@ "typeString": "string memory" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -9512,9 +9272,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2485, "type": "uint256", "value": "b" @@ -9548,9 +9306,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2487, "type": "string memory", "value": "errorMessage" @@ -9592,9 +9348,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2483, "type": "uint256", "value": "a" @@ -9606,9 +9360,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2485, "type": "uint256", "value": "b" @@ -9665,4 +9417,4 @@ "methods": {}, "version": 1 } -} \ No newline at end of file +} diff --git a/packages/bridge/contracts/WETH.json b/packages/bridge-sdk/contracts/WETH.json similarity index 96% rename from packages/bridge/contracts/WETH.json rename to packages/bridge-sdk/contracts/WETH.json index 58f452c..47241fa 100644 --- a/packages/bridge/contracts/WETH.json +++ b/packages/bridge-sdk/contracts/WETH.json @@ -216,12 +216,8 @@ "ast": { "absolutePath": "/Users/bartosz.lipinski/Workspace/wormhole/ethereum/contracts/Wormhole.sol", "exportedSymbols": { - "WETH": [ - 1431 - ], - "Wormhole": [ - 1420 - ] + "WETH": [1431], + "Wormhole": [1420] }, "id": 1432, "license": "Apache 2", @@ -229,21 +225,13 @@ "nodes": [ { "id": 335, - "literals": [ - "solidity", - "^", - "0.6", - ".0" - ], + "literals": ["solidity", "^", "0.6", ".0"], "nodeType": "PragmaDirective", "src": "64:23:1" }, { "id": 336, - "literals": [ - "experimental", - "ABIEncoderV2" - ], + "literals": ["experimental", "ABIEncoderV2"], "nodeType": "PragmaDirective", "src": "88:33:1" }, @@ -346,17 +334,12 @@ "src": "484:15:1" } ], - "contractDependencies": [ - 3658 - ], + "contractDependencies": [3658], "contractKind": "contract", "documentation": null, "fullyImplemented": true, "id": 1420, - "linearizedBaseContracts": [ - 1420, - 3658 - ], + "linearizedBaseContracts": [1420, 3658], "name": "Wormhole", "nodeType": "ContractDefinition", "nodes": [ @@ -1930,9 +1913,7 @@ "src": "2673:566:1", "statements": [ { - "assignments": [ - 476 - ], + "assignments": [476], "declarations": [ { "constant": false, @@ -2191,10 +2172,7 @@ "id": 509, "name": "revert", "nodeType": "Identifier", - "overloadedDeclarations": [ - -19, - -19 - ], + "overloadedDeclarations": [-19, -19], "referencedDeclaration": -19, "src": "3112:6:1", "typeDescriptions": { @@ -2411,10 +2389,7 @@ "id": 485, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "2813:7:1", "typeDescriptions": { @@ -2916,10 +2891,7 @@ "id": 540, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "3597:7:1", "typeDescriptions": { @@ -3067,9 +3039,7 @@ "src": "3714:47:1" }, { - "assignments": [ - 558 - ], + "assignments": [558], "declarations": [ { "constant": false, @@ -3176,9 +3146,7 @@ "src": "3772:36:1" }, { - "assignments": [ - 565 - ], + "assignments": [565], "declarations": [ { "constant": false, @@ -3741,10 +3709,7 @@ "id": 596, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "4053:7:1", "typeDescriptions": { @@ -3772,9 +3737,7 @@ "src": "4053:67:1" }, { - "assignments": [ - 606 - ], + "assignments": [606], "declarations": [ { "constant": false, @@ -3986,10 +3949,7 @@ "id": 612, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "4219:7:1", "typeDescriptions": { @@ -4215,10 +4175,7 @@ "id": 621, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "4290:7:1", "typeDescriptions": { @@ -4578,10 +4535,7 @@ "id": 635, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "4517:7:1", "typeDescriptions": { @@ -4609,9 +4563,7 @@ "src": "4517:87:1" }, { - "assignments": [ - 657 - ], + "assignments": [657], "declarations": [ { "constant": false, @@ -4687,9 +4639,7 @@ "src": "4686:465:1", "statements": [ { - "assignments": [ - 672 - ], + "assignments": [672], "declarations": [ { "constant": false, @@ -4946,10 +4896,7 @@ "id": 682, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "4751:7:1", "typeDescriptions": { @@ -5071,9 +5018,7 @@ "src": "4831:25:1" }, { - "assignments": [ - 697 - ], + "assignments": [697], "declarations": [ { "constant": false, @@ -5249,9 +5194,7 @@ "src": "4871:37:1" }, { - "assignments": [ - 708 - ], + "assignments": [708], "declarations": [ { "constant": false, @@ -5427,9 +5370,7 @@ "src": "4922:38:1" }, { - "assignments": [ - 719 - ], + "assignments": [719], "declarations": [ { "constant": false, @@ -5884,10 +5825,7 @@ "id": 733, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "5043:7:1", "typeDescriptions": { @@ -5963,9 +5901,7 @@ }, "id": 750, "initializationExpression": { - "assignments": [ - 662 - ], + "assignments": [662], "declarations": [ { "constant": false, @@ -6574,9 +6510,7 @@ "src": "5353:859:1", "statements": [ { - "assignments": [ - 787 - ], + "assignments": [787], "declarations": [ { "constant": false, @@ -6801,10 +6735,7 @@ "id": 793, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "5421:7:1", "typeDescriptions": { @@ -6832,9 +6763,7 @@ "src": "5421:94:1" }, { - "assignments": [ - 803 - ], + "assignments": [803], "declarations": [ { "constant": false, @@ -6941,9 +6870,7 @@ "src": "5525:27:1" }, { - "assignments": [ - 813 - ], + "assignments": [813], "declarations": [ { "constant": false, @@ -7067,9 +6994,7 @@ "src": "5655:103:1", "statements": [ { - "assignments": [ - 831 - ], + "assignments": [831], "declarations": [ { "constant": false, @@ -7367,9 +7292,7 @@ }, "id": 848, "initializationExpression": { - "assignments": [ - 821 - ], + "assignments": [821], "declarations": [ { "constant": false, @@ -7460,9 +7383,7 @@ "src": "5624:134:1" }, { - "assignments": [ - 850 - ], + "assignments": [850], "declarations": [ { "constant": false, @@ -7557,9 +7478,7 @@ "src": "5828:43:1" }, { - "assignments": [ - 858 - ], + "assignments": [858], "declarations": [ { "constant": false, @@ -8062,9 +7981,7 @@ "src": "6266:1644:1", "statements": [ { - "assignments": [ - 895 - ], + "assignments": [895], "declarations": [ { "constant": false, @@ -8171,9 +8088,7 @@ "src": "6319:36:1" }, { - "assignments": [ - 902 - ], + "assignments": [902], "declarations": [ { "constant": false, @@ -8280,9 +8195,7 @@ "src": "6366:36:1" }, { - "assignments": [ - 909 - ], + "assignments": [909], "declarations": [ { "constant": false, @@ -8427,9 +8340,7 @@ "src": "6521:48:1" }, { - "assignments": [ - 918 - ], + "assignments": [918], "declarations": [ { "constant": false, @@ -8536,9 +8447,7 @@ "src": "6580:36:1" }, { - "assignments": [ - 925 - ], + "assignments": [925], "declarations": [ { "constant": false, @@ -8726,10 +8635,7 @@ "id": 931, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "6727:7:1", "typeDescriptions": { @@ -8838,10 +8744,7 @@ "id": 938, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "6816:7:1", "typeDescriptions": { @@ -8920,9 +8823,7 @@ "src": "7514:390:1", "statements": [ { - "assignments": [ - 1005 - ], + "assignments": [1005], "declarations": [ { "constant": false, @@ -9067,9 +8968,7 @@ "src": "7528:47:1" }, { - "assignments": [ - 1014 - ], + "assignments": [1014], "declarations": [ { "constant": false, @@ -9608,9 +9507,7 @@ "src": "6918:590:1", "statements": [ { - "assignments": [ - 949 - ], + "assignments": [949], "declarations": [ { "constant": false, @@ -9717,9 +9614,7 @@ "src": "6932:42:1" }, { - "assignments": [ - 956 - ], + "assignments": [956], "declarations": [ { "constant": false, @@ -9875,9 +9770,7 @@ "src": "6988:74:1" }, { - "assignments": [ - 966 - ], + "assignments": [966], "declarations": [ { "constant": false, @@ -10062,9 +9955,7 @@ "src": "7248:179:1", "statements": [ { - "assignments": [ - 978 - ], + "assignments": [978], "declarations": [ { "constant": false, @@ -10499,9 +10390,7 @@ "src": "8047:808:1", "statements": [ { - "assignments": [ - 1065 - ], + "assignments": [1065], "declarations": [ { "constant": false, @@ -11375,10 +11264,7 @@ "id": 1111, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "9067:7:1", "typeDescriptions": { @@ -11406,9 +11292,7 @@ "src": "9067:72:1" }, { - "assignments": [ - 1119 - ], + "assignments": [1119], "declarations": [ { "constant": false, @@ -11457,9 +11341,7 @@ "src": "9150:28:1" }, { - "assignments": [ - 1123 - ], + "assignments": [1123], "declarations": [ { "constant": false, @@ -11496,9 +11378,7 @@ "src": "9188:21:1" }, { - "assignments": [ - 1126 - ], + "assignments": [1126], "declarations": [ { "constant": false, @@ -11664,9 +11544,7 @@ "src": "9496:1091:1", "statements": [ { - "assignments": [ - 1163 - ], + "assignments": [1163], "declarations": [ { "constant": false, @@ -12059,9 +11937,7 @@ "src": "9586:65:1" }, { - "assignments": [ - 1188 - ], + "assignments": [1188], "declarations": [ { "constant": false, @@ -12407,9 +12283,7 @@ "src": "10060:326:1", "statements": [ { - "assignments": [ - 1210 - ], + "assignments": [1210], "declarations": [ { "constant": false, @@ -13402,10 +13276,7 @@ "id": 1255, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "10400:7:1", "typeDescriptions": { @@ -14049,10 +13920,7 @@ "id": 1288, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "10636:7:1", "typeDescriptions": { @@ -14672,10 +14540,7 @@ "id": 1325, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "10980:7:1", "typeDescriptions": { @@ -14703,9 +14568,7 @@ "src": "10980:72:1" }, { - "assignments": [ - 1333 - ], + "assignments": [1333], "declarations": [ { "constant": false, @@ -14865,9 +14728,7 @@ "src": "11063:42:1" }, { - "assignments": [ - 1343 - ], + "assignments": [1343], "declarations": [ { "constant": false, @@ -15113,10 +14974,7 @@ "id": 1352, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "11173:7:1", "typeDescriptions": { @@ -15307,9 +15165,7 @@ "isLValue": false, "isPure": false, "lValueRequested": false, - "names": [ - "value" - ], + "names": ["value"], "nodeType": "FunctionCallOptions", "options": [ { @@ -15959,10 +15815,7 @@ "id": 1406, "name": "revert", "nodeType": "Identifier", - "overloadedDeclarations": [ - -19, - -19 - ], + "overloadedDeclarations": [-19, -19], "referencedDeclaration": -19, "src": "11641:6:1", "typeDescriptions": { @@ -16056,10 +15909,7 @@ "id": 1414, "name": "revert", "nodeType": "Identifier", - "overloadedDeclarations": [ - -19, - -19 - ], + "overloadedDeclarations": [-19, -19], "referencedDeclaration": -19, "src": "11731:6:1", "typeDescriptions": { @@ -16140,17 +15990,12 @@ "src": "11810:6:1" } ], - "contractDependencies": [ - 3086 - ], + "contractDependencies": [3086], "contractKind": "interface", "documentation": null, "fullyImplemented": false, "id": 1431, - "linearizedBaseContracts": [ - 1431, - 3086 - ], + "linearizedBaseContracts": [1431, 3086], "name": "WETH", "nodeType": "ContractDefinition", "nodes": [ @@ -16252,24 +16097,15 @@ "attributes": { "absolutePath": "/Users/bartosz.lipinski/Workspace/wormhole/ethereum/contracts/Wormhole.sol", "exportedSymbols": { - "WETH": [ - 1431 - ], - "Wormhole": [ - 1420 - ] + "WETH": [1431], + "Wormhole": [1420] }, "license": "Apache 2" }, "children": [ { "attributes": { - "literals": [ - "solidity", - "^", - "0.6", - ".0" - ] + "literals": ["solidity", "^", "0.6", ".0"] }, "id": 335, "name": "PragmaDirective", @@ -16277,10 +16113,7 @@ }, { "attributes": { - "literals": [ - "experimental", - "ABIEncoderV2" - ] + "literals": ["experimental", "ABIEncoderV2"] }, "id": 336, "name": "PragmaDirective", @@ -16292,9 +16125,7 @@ "absolutePath": "@openzeppelin/contracts/token/ERC20/ERC20.sol", "file": "@openzeppelin/contracts/token/ERC20/ERC20.sol", "scope": 1432, - "symbolAliases": [ - null - ], + "symbolAliases": [null], "unitAlias": "" }, "id": 337, @@ -16307,9 +16138,7 @@ "absolutePath": "@openzeppelin/contracts/token/ERC20/IERC20.sol", "file": "@openzeppelin/contracts/token/ERC20/IERC20.sol", "scope": 1432, - "symbolAliases": [ - null - ], + "symbolAliases": [null], "unitAlias": "" }, "id": 338, @@ -16322,9 +16151,7 @@ "absolutePath": "@openzeppelin/contracts/token/ERC20/SafeERC20.sol", "file": "@openzeppelin/contracts/token/ERC20/SafeERC20.sol", "scope": 1432, - "symbolAliases": [ - null - ], + "symbolAliases": [null], "unitAlias": "" }, "id": 339, @@ -16337,9 +16164,7 @@ "absolutePath": "@openzeppelin/contracts/math/SafeMath.sol", "file": "@openzeppelin/contracts/math/SafeMath.sol", "scope": 1432, - "symbolAliases": [ - null - ], + "symbolAliases": [null], "unitAlias": "" }, "id": 340, @@ -16352,9 +16177,7 @@ "absolutePath": "@openzeppelin/contracts/utils/ReentrancyGuard.sol", "file": "@openzeppelin/contracts/utils/ReentrancyGuard.sol", "scope": 1432, - "symbolAliases": [ - null - ], + "symbolAliases": [null], "unitAlias": "" }, "id": 341, @@ -16367,9 +16190,7 @@ "absolutePath": "/Users/bartosz.lipinski/Workspace/wormhole/ethereum/contracts/BytesLib.sol", "file": "./BytesLib.sol", "scope": 1432, - "symbolAliases": [ - null - ], + "symbolAliases": [null], "unitAlias": "" }, "id": 342, @@ -16382,9 +16203,7 @@ "absolutePath": "/Users/bartosz.lipinski/Workspace/wormhole/ethereum/contracts/WrappedAsset.sol", "file": "./WrappedAsset.sol", "scope": 1432, - "symbolAliases": [ - null - ], + "symbolAliases": [null], "unitAlias": "" }, "id": 343, @@ -16394,16 +16213,11 @@ { "attributes": { "abstract": false, - "contractDependencies": [ - 3658 - ], + "contractDependencies": [3658], "contractKind": "contract", "documentation": null, "fullyImplemented": true, - "linearizedBaseContracts": [ - 1420, - 3658 - ], + "linearizedBaseContracts": [1420, 3658], "name": "Wormhole", "scope": 1432 }, @@ -17524,9 +17338,7 @@ "implemented": true, "isConstructor": true, "kind": "constructor", - "modifiers": [ - null - ], + "modifiers": [null], "name": "", "overrides": null, "scope": 1420, @@ -17631,9 +17443,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 436, @@ -17668,9 +17478,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 412, "type": "mapping(uint32 => struct Wormhole.GuardianSet storage ref)", "value": "guardian_sets" @@ -17704,9 +17512,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 430, "type": "struct Wormhole.GuardianSet memory", "value": "initial_guardian_set" @@ -17741,9 +17547,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 414, "type": "uint32", "value": "guardian_set_index" @@ -17795,9 +17599,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 416, "type": "uint32", "value": "guardian_set_expirity" @@ -17809,9 +17611,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 434, "type": "uint32", "value": "_guardian_set_expirity" @@ -17846,9 +17646,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 359, "type": "address", "value": "wrappedAssetMaster" @@ -17860,9 +17658,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 432, "type": "address", "value": "wrapped_asset_master" @@ -17898,9 +17694,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "getGuardianSet", "overrides": null, "scope": 1420, @@ -18001,9 +17795,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 412, "type": "mapping(uint32 => struct Wormhole.GuardianSet storage ref)", "value": "guardian_sets" @@ -18015,9 +17807,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 458, "type": "uint32", "value": "idx" @@ -18098,9 +17888,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 474, @@ -18115,9 +17903,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3657, "type": "modifier ()", "value": "nonReentrant" @@ -18135,9 +17921,7 @@ "children": [ { "attributes": { - "assignments": [ - 476 - ] + "assignments": [476] }, "children": [ { @@ -18178,9 +17962,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "struct Wormhole.ParsedVAA memory", "type_conversion": false @@ -18194,9 +17976,7 @@ "typeString": "bytes calldata" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 781, "type": "function (bytes calldata) view returns (struct Wormhole.ParsedVAA memory)", "value": "parseAndVerifyVAA" @@ -18208,9 +17988,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 470, "type": "bytes calldata", "value": "vaa" @@ -18261,9 +18039,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 476, "type": "struct Wormhole.ParsedVAA memory", "value": "parsed_vaa" @@ -18311,9 +18087,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -18331,10 +18105,7 @@ "typeString": "literal_string \"only the current guardian set can change the guardian set\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -18373,9 +18144,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 476, "type": "struct Wormhole.ParsedVAA memory", "value": "parsed_vaa" @@ -18392,9 +18161,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 414, "type": "uint32", "value": "guardian_set_index" @@ -18445,9 +18212,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -18461,9 +18226,7 @@ "typeString": "bytes memory" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 889, "type": "function (bytes memory)", "value": "vaaUpdateGuardianSet" @@ -18487,9 +18250,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 476, "type": "struct Wormhole.ParsedVAA memory", "value": "parsed_vaa" @@ -18550,9 +18311,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 476, "type": "struct Wormhole.ParsedVAA memory", "value": "parsed_vaa" @@ -18600,9 +18359,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -18616,9 +18373,7 @@ "typeString": "bytes memory" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1051, "type": "function (bytes memory)", "value": "vaaTransfer" @@ -18642,9 +18397,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 476, "type": "struct Wormhole.ParsedVAA memory", "value": "parsed_vaa" @@ -18685,9 +18438,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -18701,10 +18452,7 @@ "typeString": "literal_string \"invalid VAA action\"" } ], - "overloadedDeclarations": [ - -19, - -19 - ], + "overloadedDeclarations": [-19, -19], "referencedDeclaration": -19, "type": "function (string memory) pure", "value": "revert" @@ -18781,9 +18529,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 420, "type": "mapping(bytes32 => bool)", "value": "consumedVAAs" @@ -18807,9 +18553,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 476, "type": "struct Wormhole.ParsedVAA memory", "value": "parsed_vaa" @@ -18872,9 +18616,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "parseAndVerifyVAA", "overrides": null, "scope": 1420, @@ -18985,9 +18727,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 529, "type": "struct Wormhole.ParsedVAA memory", "value": "parsed_vaa" @@ -19009,9 +18749,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint8", "type_conversion": false @@ -19037,9 +18775,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 526, "type": "bytes calldata", "value": "vaa" @@ -19095,9 +18831,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -19115,10 +18849,7 @@ "typeString": "literal_string \"VAA version incompatible\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -19157,9 +18888,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 529, "type": "struct Wormhole.ParsedVAA memory", "value": "parsed_vaa" @@ -19250,9 +18979,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 529, "type": "struct Wormhole.ParsedVAA memory", "value": "parsed_vaa" @@ -19274,9 +19001,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint32", "type_conversion": false @@ -19302,9 +19027,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 526, "type": "bytes calldata", "value": "vaa" @@ -19352,9 +19075,7 @@ }, { "attributes": { - "assignments": [ - 558 - ] + "assignments": [558] }, "children": [ { @@ -19393,9 +19114,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint8", "type_conversion": false @@ -19421,9 +19140,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 526, "type": "bytes calldata", "value": "vaa" @@ -19466,9 +19183,7 @@ }, { "attributes": { - "assignments": [ - 565 - ] + "assignments": [565] }, "children": [ { @@ -19566,9 +19281,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 558, "type": "uint256", "value": "len_signers" @@ -19620,9 +19333,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 529, "type": "struct Wormhole.ParsedVAA memory", "value": "parsed_vaa" @@ -19644,9 +19355,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint32", "type_conversion": false @@ -19672,9 +19381,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 526, "type": "bytes calldata", "value": "vaa" @@ -19691,9 +19398,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 565, "type": "uint256", "value": "offset" @@ -19745,9 +19450,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 529, "type": "struct Wormhole.ParsedVAA memory", "value": "parsed_vaa" @@ -19769,9 +19472,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes32", "type_conversion": false @@ -19785,9 +19486,7 @@ "typeString": "bytes memory" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -8, "type": "function (bytes memory) pure returns (bytes32)", "value": "keccak256" @@ -19804,9 +19503,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes memory", "type_conversion": false @@ -19836,9 +19533,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 526, "type": "bytes calldata", "value": "vaa" @@ -19855,9 +19550,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 565, "type": "uint256", "value": "offset" @@ -19896,9 +19589,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 526, "type": "bytes calldata", "value": "vaa" @@ -19915,9 +19606,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 565, "type": "uint256", "value": "offset" @@ -19961,9 +19650,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -19981,10 +19668,7 @@ "typeString": "literal_string \"VAA was already executed\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -20018,9 +19702,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 420, "type": "mapping(bytes32 => bool)", "value": "consumedVAAs" @@ -20044,9 +19726,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 529, "type": "struct Wormhole.ParsedVAA memory", "value": "parsed_vaa" @@ -20099,9 +19779,7 @@ }, { "attributes": { - "assignments": [ - 606 - ] + "assignments": [606] }, "children": [ { @@ -20147,9 +19825,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 412, "type": "mapping(uint32 => struct Wormhole.GuardianSet storage ref)", "value": "guardian_sets" @@ -20173,9 +19849,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 529, "type": "struct Wormhole.ParsedVAA memory", "value": "parsed_vaa" @@ -20209,9 +19883,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -20229,10 +19901,7 @@ "typeString": "literal_string \"invalid guardian set\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -20283,9 +19952,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 606, "type": "struct Wormhole.GuardianSet memory", "value": "guardian_set" @@ -20363,9 +20030,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -20383,10 +20048,7 @@ "typeString": "literal_string \"guardian set has expired\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -20440,9 +20102,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 606, "type": "struct Wormhole.GuardianSet memory", "value": "guardian_set" @@ -20508,9 +20168,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 606, "type": "struct Wormhole.GuardianSet memory", "value": "guardian_set" @@ -20539,9 +20197,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -4, "type": "block", "value": "block" @@ -20602,9 +20258,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -20622,10 +20276,7 @@ "typeString": "literal_string \"no quorum\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -20917,9 +20568,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 558, "type": "uint256", "value": "len_signers" @@ -20962,9 +20611,7 @@ }, { "attributes": { - "assignments": [ - 657 - ] + "assignments": [657] }, "children": [ { @@ -21038,9 +20685,7 @@ "children": [ { "attributes": { - "assignments": [ - 662 - ] + "assignments": [662] }, "children": [ { @@ -21111,9 +20756,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 662, "type": "uint256", "value": "i" @@ -21125,9 +20768,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 558, "type": "uint256", "value": "len_signers" @@ -21158,9 +20799,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 662, "type": "uint256", "value": "i" @@ -21183,9 +20822,7 @@ "children": [ { "attributes": { - "assignments": [ - 672 - ] + "assignments": [672] }, "children": [ { @@ -21224,9 +20861,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint8", "type_conversion": false @@ -21252,9 +20887,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 526, "type": "bytes calldata", "value": "vaa" @@ -21318,9 +20951,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 662, "type": "uint256", "value": "i" @@ -21376,9 +21007,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -21396,10 +21025,7 @@ "typeString": "literal_string \"signature indices must be ascending\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -21426,9 +21052,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 672, "type": "uint8", "value": "index" @@ -21440,9 +21064,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 657, "type": "int16", "value": "last_index" @@ -21499,9 +21121,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 657, "type": "int16", "value": "last_index" @@ -21518,9 +21138,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "int16", "type_conversion": true @@ -21558,9 +21176,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 672, "type": "uint8", "value": "index" @@ -21586,9 +21202,7 @@ }, { "attributes": { - "assignments": [ - 697 - ] + "assignments": [697] }, "children": [ { @@ -21627,9 +21241,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes32", "type_conversion": false @@ -21655,9 +21267,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 526, "type": "bytes calldata", "value": "vaa" @@ -21721,9 +21331,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 662, "type": "uint256", "value": "i" @@ -21771,9 +21379,7 @@ }, { "attributes": { - "assignments": [ - 708 - ] + "assignments": [708] }, "children": [ { @@ -21812,9 +21418,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes32", "type_conversion": false @@ -21840,9 +21444,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 526, "type": "bytes calldata", "value": "vaa" @@ -21906,9 +21508,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 662, "type": "uint256", "value": "i" @@ -21956,9 +21556,7 @@ }, { "attributes": { - "assignments": [ - 719 - ] + "assignments": [719] }, "children": [ { @@ -21997,9 +21595,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint8", "type_conversion": false @@ -22025,9 +21621,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 526, "type": "bytes calldata", "value": "vaa" @@ -22091,9 +21685,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 662, "type": "uint256", "value": "i" @@ -22155,9 +21747,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 719, "type": "uint8", "value": "v" @@ -22203,9 +21793,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -22223,10 +21811,7 @@ "typeString": "literal_string \"VAA signature invalid\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -22258,9 +21843,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address", "type_conversion": false @@ -22286,9 +21869,7 @@ "typeString": "bytes32" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -6, "type": "function (bytes32,uint8,bytes32,bytes32) pure returns (address)", "value": "ecrecover" @@ -22331,9 +21912,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 719, "type": "uint8", "value": "v" @@ -22345,9 +21924,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 697, "type": "bytes32", "value": "r" @@ -22359,9 +21936,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 708, "type": "bytes32", "value": "s" @@ -22419,9 +21994,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 672, "type": "uint8", "value": "index" @@ -22505,9 +22078,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 529, "type": "struct Wormhole.ParsedVAA memory", "value": "parsed_vaa" @@ -22529,9 +22100,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint8", "type_conversion": false @@ -22557,9 +22126,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 526, "type": "bytes calldata", "value": "vaa" @@ -22591,9 +22158,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 565, "type": "uint256", "value": "offset" @@ -22667,9 +22232,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 529, "type": "struct Wormhole.ParsedVAA memory", "value": "parsed_vaa" @@ -22691,9 +22254,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes memory", "type_conversion": false @@ -22723,9 +22284,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 526, "type": "bytes calldata", "value": "vaa" @@ -22757,9 +22316,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 565, "type": "uint256", "value": "offset" @@ -22820,9 +22377,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 526, "type": "bytes calldata", "value": "vaa" @@ -22865,9 +22420,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 565, "type": "uint256", "value": "offset" @@ -22939,9 +22492,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "vaaUpdateGuardianSet", "overrides": null, "scope": 1420, @@ -22987,9 +22538,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 785, @@ -23000,9 +22549,7 @@ "children": [ { "attributes": { - "assignments": [ - 787 - ] + "assignments": [787] }, "children": [ { @@ -23041,9 +22588,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint32", "type_conversion": false @@ -23069,9 +22614,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 783, "type": "bytes memory", "value": "data" @@ -23122,9 +22665,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -23142,10 +22683,7 @@ "typeString": "literal_string \"index must increase in steps of 1\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -23172,9 +22710,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 787, "type": "uint32", "value": "new_guardian_set_index" @@ -23201,9 +22737,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 414, "type": "uint32", "value": "guardian_set_index" @@ -23268,9 +22802,7 @@ }, { "attributes": { - "assignments": [ - 803 - ] + "assignments": [803] }, "children": [ { @@ -23309,9 +22841,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint8", "type_conversion": false @@ -23337,9 +22867,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 783, "type": "bytes memory", "value": "data" @@ -23382,9 +22910,7 @@ }, { "attributes": { - "assignments": [ - 813 - ] + "assignments": [813] }, "children": [ { @@ -23434,9 +22960,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address[] memory", "type_conversion": false @@ -23486,9 +23010,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 803, "type": "uint8", "value": "len" @@ -23511,9 +23033,7 @@ "children": [ { "attributes": { - "assignments": [ - 821 - ] + "assignments": [821] }, "children": [ { @@ -23584,9 +23104,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 821, "type": "uint256", "value": "i" @@ -23598,9 +23116,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 803, "type": "uint8", "value": "len" @@ -23631,9 +23147,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 821, "type": "uint256", "value": "i" @@ -23656,9 +23170,7 @@ "children": [ { "attributes": { - "assignments": [ - 831 - ] + "assignments": [831] }, "children": [ { @@ -23698,9 +23210,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address", "type_conversion": false @@ -23726,9 +23236,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 783, "type": "bytes memory", "value": "data" @@ -23792,9 +23300,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 821, "type": "uint256", "value": "i" @@ -23866,9 +23372,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 813, "type": "address[] memory", "value": "new_guardians" @@ -23880,9 +23384,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 821, "type": "uint256", "value": "i" @@ -23899,9 +23401,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 831, "type": "address", "value": "addr" @@ -23932,9 +23432,7 @@ }, { "attributes": { - "assignments": [ - 850 - ] + "assignments": [850] }, "children": [ { @@ -23968,9 +23466,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 414, "type": "uint32", "value": "guardian_set_index" @@ -24000,9 +23496,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 414, "type": "uint32", "value": "guardian_set_index" @@ -24014,9 +23508,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 787, "type": "uint32", "value": "new_guardian_set_index" @@ -24037,9 +23529,7 @@ }, { "attributes": { - "assignments": [ - 858 - ] + "assignments": [858] }, "children": [ { @@ -24080,9 +23570,7 @@ "isPure": false, "isStructConstructorCall": true, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "struct Wormhole.GuardianSet memory", "type_conversion": false @@ -24100,9 +23588,7 @@ "typeString": "int_const 0" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 371, "type": "type(struct Wormhole.GuardianSet storage pointer)", "value": "GuardianSet" @@ -24114,9 +23600,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 813, "type": "address[] memory", "value": "new_guardians" @@ -24178,9 +23662,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 412, "type": "mapping(uint32 => struct Wormhole.GuardianSet storage ref)", "value": "guardian_sets" @@ -24192,9 +23674,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 414, "type": "uint32", "value": "guardian_set_index" @@ -24211,9 +23691,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 858, "type": "struct Wormhole.GuardianSet memory", "value": "new_guardian_set" @@ -24270,9 +23748,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 412, "type": "mapping(uint32 => struct Wormhole.GuardianSet storage ref)", "value": "guardian_sets" @@ -24284,9 +23760,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 850, "type": "uint32", "value": "old_guardian_set_index" @@ -24328,9 +23802,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint32", "type_conversion": true @@ -24380,9 +23852,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -4, "type": "block", "value": "block" @@ -24404,9 +23874,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 416, "type": "uint32", "value": "guardian_set_expirity" @@ -24440,9 +23908,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -24460,9 +23926,7 @@ "typeString": "uint32" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 377, "type": "function (uint32,uint32)", "value": "LogGuardianSetChanged" @@ -24474,9 +23938,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 850, "type": "uint32", "value": "old_guardian_set_index" @@ -24488,9 +23950,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 414, "type": "uint32", "value": "guardian_set_index" @@ -24525,9 +23985,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "vaaTransfer", "overrides": null, "scope": 1420, @@ -24573,9 +24031,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 893, @@ -24586,9 +24042,7 @@ "children": [ { "attributes": { - "assignments": [ - 895 - ] + "assignments": [895] }, "children": [ { @@ -24627,9 +24081,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint8", "type_conversion": false @@ -24655,9 +24107,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 891, "type": "bytes memory", "value": "data" @@ -24700,9 +24150,7 @@ }, { "attributes": { - "assignments": [ - 902 - ] + "assignments": [902] }, "children": [ { @@ -24741,9 +24189,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint8", "type_conversion": false @@ -24769,9 +24215,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 891, "type": "bytes memory", "value": "data" @@ -24814,9 +24258,7 @@ }, { "attributes": { - "assignments": [ - 909 - ] + "assignments": [909] }, "children": [ { @@ -24856,9 +24298,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address", "type_conversion": false @@ -24884,9 +24324,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 891, "type": "bytes memory", "value": "data" @@ -24966,9 +24404,7 @@ }, { "attributes": { - "assignments": [ - 918 - ] + "assignments": [918] }, "children": [ { @@ -25007,9 +24443,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint8", "type_conversion": false @@ -25035,9 +24469,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 891, "type": "bytes memory", "value": "data" @@ -25080,9 +24512,7 @@ }, { "attributes": { - "assignments": [ - 925 - ] + "assignments": [925] }, "children": [ { @@ -25121,9 +24551,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -25149,9 +24577,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 891, "type": "bytes memory", "value": "data" @@ -25202,9 +24628,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -25222,10 +24646,7 @@ "typeString": "literal_string \"same chain transfers are not supported\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -25252,9 +24673,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 895, "type": "uint8", "value": "source_chain" @@ -25266,9 +24685,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 902, "type": "uint8", "value": "target_chain" @@ -25319,9 +24736,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -25339,10 +24754,7 @@ "typeString": "literal_string \"transfer must be incoming\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -25369,9 +24781,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 902, "type": "uint8", "value": "target_chain" @@ -25383,9 +24793,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 362, "type": "uint8", "value": "CHAIN_ID" @@ -25446,9 +24854,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 918, "type": "uint8", "value": "token_chain" @@ -25460,9 +24866,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 362, "type": "uint8", "value": "CHAIN_ID" @@ -25480,9 +24884,7 @@ "children": [ { "attributes": { - "assignments": [ - 949 - ] + "assignments": [949] }, "children": [ { @@ -25521,9 +24923,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes32", "type_conversion": false @@ -25549,9 +24949,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 891, "type": "bytes memory", "value": "data" @@ -25594,9 +24992,7 @@ }, { "attributes": { - "assignments": [ - 956 - ] + "assignments": [956] }, "children": [ { @@ -25635,9 +25031,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes32", "type_conversion": false @@ -25651,9 +25045,7 @@ "typeString": "bytes memory" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -8, "type": "function (bytes memory) pure returns (bytes32)", "value": "keccak256" @@ -25670,9 +25062,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes memory", "type_conversion": false @@ -25702,9 +25092,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -1, "type": "abi", "value": "abi" @@ -25721,9 +25109,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 918, "type": "uint8", "value": "token_chain" @@ -25735,9 +25121,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 949, "type": "bytes32", "value": "token_address" @@ -25763,9 +25147,7 @@ }, { "attributes": { - "assignments": [ - 966 - ] + "assignments": [966] }, "children": [ { @@ -25810,9 +25192,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 424, "type": "mapping(bytes32 => address)", "value": "wrappedAssets" @@ -25824,9 +25204,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 956, "type": "bytes32", "value": "asset_id" @@ -25868,9 +25246,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 966, "type": "address", "value": "wrapped_asset" @@ -25887,9 +25263,7 @@ "isPure": true, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": true @@ -25955,9 +25329,7 @@ "children": [ { "attributes": { - "assignments": [ - 978 - ] + "assignments": [978] }, "children": [ { @@ -25996,9 +25368,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint8", "type_conversion": false @@ -26083,9 +25453,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 966, "type": "address", "value": "wrapped_asset" @@ -26102,9 +25470,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address", "type_conversion": false @@ -26232,9 +25598,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -26269,9 +25633,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "contract WrappedAsset", "type_conversion": true @@ -26285,9 +25647,7 @@ "typeString": "address" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2147, "type": "type(contract WrappedAsset)", "value": "WrappedAsset" @@ -26299,9 +25659,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 966, "type": "address", "value": "wrapped_asset" @@ -26323,9 +25681,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 909, "type": "address", "value": "target_address" @@ -26337,9 +25693,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 925, "type": "uint256", "value": "amount" @@ -26367,9 +25721,7 @@ "children": [ { "attributes": { - "assignments": [ - 1005 - ] + "assignments": [1005] }, "children": [ { @@ -26409,9 +25761,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address", "type_conversion": false @@ -26437,9 +25787,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 891, "type": "bytes memory", "value": "data" @@ -26519,9 +25867,7 @@ }, { "attributes": { - "assignments": [ - 1014 - ] + "assignments": [1014] }, "children": [ { @@ -26555,17 +25901,13 @@ { "attributes": { "argumentTypes": null, - "arguments": [ - null - ], + "arguments": [null], "isConstant": false, "isLValue": false, "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint8", "type_conversion": false @@ -26573,9 +25915,7 @@ "children": [ { "attributes": { - "argumentTypes": [ - null - ], + "argumentTypes": [null], "isConstant": false, "isLValue": false, "isPure": false, @@ -26593,9 +25933,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "contract ERC20", "type_conversion": true @@ -26609,9 +25947,7 @@ "typeString": "address" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3008, "type": "type(contract ERC20)", "value": "ERC20" @@ -26623,9 +25959,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1005, "type": "address", "value": "token_address" @@ -26677,9 +26011,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1014, "type": "uint8", "value": "decimals" @@ -26728,9 +26060,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 925, "type": "uint256", "value": "amount" @@ -26747,9 +26077,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -26831,9 +26159,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": true @@ -26964,9 +26290,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -27001,9 +26325,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "contract IERC20", "type_conversion": true @@ -27017,9 +26339,7 @@ "typeString": "address" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3086, "type": "type(contract IERC20)", "value": "IERC20" @@ -27031,9 +26351,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1005, "type": "address", "value": "token_address" @@ -27055,9 +26373,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 909, "type": "address", "value": "target_address" @@ -27069,9 +26385,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 925, "type": "uint256", "value": "amount" @@ -27116,9 +26430,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "deployWrappedAsset", "overrides": null, "scope": 1420, @@ -27286,9 +26598,7 @@ "children": [ { "attributes": { - "assignments": [ - 1065 - ] + "assignments": [1065] }, "children": [ { @@ -27327,9 +26637,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes20", "type_conversion": true @@ -27367,9 +26675,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 359, "type": "address", "value": "wrappedAssetMaster" @@ -27431,9 +26737,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -27472,9 +26776,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "contract WrappedAsset", "type_conversion": true @@ -27488,9 +26790,7 @@ "typeString": "address" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2147, "type": "type(contract WrappedAsset)", "value": "WrappedAsset" @@ -27502,9 +26802,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1062, "type": "address", "value": "asset" @@ -27526,9 +26824,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1055, "type": "uint8", "value": "token_chain" @@ -27540,9 +26836,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1057, "type": "bytes32", "value": "token_address" @@ -27554,9 +26848,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1059, "type": "uint8", "value": "decimals" @@ -27601,9 +26893,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 424, "type": "mapping(bytes32 => address)", "value": "wrappedAssets" @@ -27615,9 +26905,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1053, "type": "bytes32", "value": "seed" @@ -27634,9 +26922,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1062, "type": "address", "value": "asset" @@ -27681,9 +26967,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 428, "type": "mapping(address => bool)", "value": "isWrappedAsset" @@ -27695,9 +26979,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1062, "type": "address", "value": "asset" @@ -27941,9 +27223,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 1110, @@ -27958,9 +27238,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3657, "type": "modifier ()", "value": "nonReentrant" @@ -27986,9 +27264,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -28006,10 +27282,7 @@ "typeString": "literal_string \"must not transfer to the same chain\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -28036,9 +27309,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1102, "type": "uint8", "value": "target_chain" @@ -28050,9 +27321,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 362, "type": "uint8", "value": "CHAIN_ID" @@ -28095,9 +27364,7 @@ }, { "attributes": { - "assignments": [ - 1119 - ] + "assignments": [1119] }, "children": [ { @@ -28131,9 +27398,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 362, "type": "uint8", "value": "CHAIN_ID" @@ -28149,9 +27414,7 @@ }, { "attributes": { - "assignments": [ - 1123 - ], + "assignments": [1123], "initialValue": null }, "children": [ @@ -28190,9 +27453,7 @@ }, { "attributes": { - "assignments": [ - 1126 - ] + "assignments": [1126] }, "children": [ { @@ -28226,17 +27487,13 @@ { "attributes": { "argumentTypes": null, - "arguments": [ - null - ], + "arguments": [null], "isConstant": false, "isLValue": false, "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint8", "type_conversion": false @@ -28244,9 +27501,7 @@ "children": [ { "attributes": { - "argumentTypes": [ - null - ], + "argumentTypes": [null], "isConstant": false, "isLValue": false, "isPure": false, @@ -28264,9 +27519,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "contract ERC20", "type_conversion": true @@ -28280,9 +27533,7 @@ "typeString": "address" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3008, "type": "type(contract ERC20)", "value": "ERC20" @@ -28294,9 +27545,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1096, "type": "address", "value": "asset" @@ -28340,9 +27589,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 428, "type": "mapping(address => bool)", "value": "isWrappedAsset" @@ -28354,9 +27601,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1096, "type": "address", "value": "asset" @@ -28382,9 +27627,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -28419,9 +27662,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "contract WrappedAsset", "type_conversion": true @@ -28435,9 +27676,7 @@ "typeString": "address" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2147, "type": "type(contract WrappedAsset)", "value": "WrappedAsset" @@ -28449,9 +27688,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1096, "type": "address", "value": "asset" @@ -28485,9 +27722,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -15, "type": "msg", "value": "msg" @@ -28504,9 +27739,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1098, "type": "uint256", "value": "amount" @@ -28541,9 +27774,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1119, "type": "uint8", "value": "asset_chain" @@ -28555,17 +27786,13 @@ { "attributes": { "argumentTypes": null, - "arguments": [ - null - ], + "arguments": [null], "isConstant": false, "isLValue": false, "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint8", "type_conversion": false @@ -28573,9 +27800,7 @@ "children": [ { "attributes": { - "argumentTypes": [ - null - ], + "argumentTypes": [null], "isConstant": false, "isLValue": false, "isPure": false, @@ -28593,9 +27818,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "contract WrappedAsset", "type_conversion": true @@ -28675,9 +27898,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1123, "type": "bytes32", "value": "asset_address" @@ -28689,17 +27910,13 @@ { "attributes": { "argumentTypes": null, - "arguments": [ - null - ], + "arguments": [null], "isConstant": false, "isLValue": false, "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes32", "type_conversion": false @@ -28707,9 +27924,7 @@ "children": [ { "attributes": { - "argumentTypes": [ - null - ], + "argumentTypes": [null], "isConstant": false, "isLValue": false, "isPure": false, @@ -28727,9 +27942,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "contract WrappedAsset", "type_conversion": true @@ -28802,9 +28015,7 @@ "children": [ { "attributes": { - "assignments": [ - 1163 - ] + "assignments": [1163] }, "children": [ { @@ -28843,9 +28054,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -28876,9 +28085,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "contract IERC20", "type_conversion": true @@ -28892,9 +28099,7 @@ "typeString": "address" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3086, "type": "type(contract IERC20)", "value": "IERC20" @@ -28906,9 +28111,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1096, "type": "address", "value": "asset" @@ -28935,9 +28138,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": true @@ -28975,9 +28176,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -28, "type": "contract Wormhole", "value": "this" @@ -29011,9 +28210,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -29052,9 +28249,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "contract IERC20", "type_conversion": true @@ -29068,9 +28263,7 @@ "typeString": "address" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3086, "type": "type(contract IERC20)", "value": "IERC20" @@ -29082,9 +28275,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1096, "type": "address", "value": "asset" @@ -29118,9 +28309,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -15, "type": "msg", "value": "msg" @@ -29142,9 +28331,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": true @@ -29182,9 +28369,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -28, "type": "contract Wormhole", "value": "this" @@ -29201,9 +28386,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1098, "type": "uint256", "value": "amount" @@ -29224,9 +28407,7 @@ }, { "attributes": { - "assignments": [ - 1188 - ] + "assignments": [1188] }, "children": [ { @@ -29265,9 +28446,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -29298,9 +28477,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "contract IERC20", "type_conversion": true @@ -29314,9 +28491,7 @@ "typeString": "address" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3086, "type": "type(contract IERC20)", "value": "IERC20" @@ -29328,9 +28503,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1096, "type": "address", "value": "asset" @@ -29357,9 +28530,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": true @@ -29397,9 +28568,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -28, "type": "contract Wormhole", "value": "this" @@ -29439,9 +28608,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1098, "type": "uint256", "value": "amount" @@ -29458,9 +28625,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -29486,9 +28651,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1188, "type": "uint256", "value": "balanceAfter" @@ -29505,9 +28668,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1163, "type": "uint256", "value": "balanceBefore" @@ -29554,9 +28715,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1126, "type": "uint8", "value": "decimals" @@ -29591,9 +28750,7 @@ "children": [ { "attributes": { - "assignments": [ - 1210 - ] + "assignments": [1210] }, "children": [ { @@ -29627,9 +28784,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1098, "type": "uint256", "value": "amount" @@ -29659,9 +28814,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1098, "type": "uint256", "value": "amount" @@ -29678,9 +28831,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -29762,9 +28913,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": true @@ -29883,9 +29032,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1106, "type": "bool", "value": "refund_dust" @@ -29906,9 +29053,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -29943,9 +29088,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "contract IERC20", "type_conversion": true @@ -30033,9 +29176,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -30117,9 +29258,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": true @@ -30256,9 +29395,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1126, "type": "uint8", "value": "decimals" @@ -30314,9 +29451,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -30334,10 +29469,7 @@ "typeString": "literal_string \"bridge balance would exceed maximum\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -30369,9 +29501,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -30453,9 +29583,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": true @@ -30508,17 +29636,13 @@ { "attributes": { "argumentTypes": null, - "arguments": [ - null - ], + "arguments": [null], "isConstant": false, "isLValue": false, "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint8", "type_conversion": false @@ -30642,9 +29766,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 357, "type": "uint64", "value": "MAX_UINT64" @@ -30701,9 +29823,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1123, "type": "bytes32", "value": "asset_address" @@ -30720,9 +29840,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes32", "type_conversion": true @@ -30765,9 +29883,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": true @@ -30805,9 +29921,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1096, "type": "address", "value": "asset" @@ -30856,9 +29970,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -30876,10 +29988,7 @@ "typeString": "literal_string \"truncated amount must not be 0\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -30906,9 +30015,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1098, "type": "uint256", "value": "amount" @@ -30976,9 +30083,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -31020,9 +30125,7 @@ "typeString": "uint32" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 395, "type": "function (uint8,uint8,uint8,bytes32,bytes32,bytes32,uint256,uint32)", "value": "LogTokensLocked" @@ -31034,9 +30137,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1102, "type": "uint8", "value": "target_chain" @@ -31048,9 +30149,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1119, "type": "uint8", "value": "asset_chain" @@ -31062,9 +30161,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1126, "type": "uint8", "value": "decimals" @@ -31076,9 +30173,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1123, "type": "bytes32", "value": "asset_address" @@ -31095,9 +30190,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes32", "type_conversion": true @@ -31140,9 +30233,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": true @@ -31192,9 +30283,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -15, "type": "msg", "value": "msg" @@ -31221,9 +30310,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1100, "type": "bytes32", "value": "recipient" @@ -31235,9 +30322,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1098, "type": "uint256", "value": "amount" @@ -31249,9 +30334,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1104, "type": "uint32", "value": "nonce" @@ -31388,9 +30471,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 1324, @@ -31405,9 +30486,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3657, "type": "modifier ()", "value": "nonReentrant" @@ -31433,9 +30512,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -31453,10 +30530,7 @@ "typeString": "literal_string \"must not transfer to the same chain\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -31483,9 +30557,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1318, "type": "uint8", "value": "target_chain" @@ -31497,9 +30569,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 362, "type": "uint8", "value": "CHAIN_ID" @@ -31542,9 +30612,7 @@ }, { "attributes": { - "assignments": [ - 1333 - ] + "assignments": [1333] }, "children": [ { @@ -31583,9 +30651,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -31623,9 +30689,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -15, "type": "msg", "value": "msg" @@ -31710,9 +30774,7 @@ }, { "attributes": { - "assignments": [ - 1343 - ] + "assignments": [1343] }, "children": [ { @@ -31751,9 +30813,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -31791,9 +30851,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -15, "type": "msg", "value": "msg" @@ -31886,9 +30944,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -31906,10 +30962,7 @@ "typeString": "literal_string \"truncated amount must not be 0\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -31936,9 +30989,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1343, "type": "uint256", "value": "transfer_amount" @@ -32006,9 +31057,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -32046,9 +31095,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -15, "type": "msg", "value": "msg" @@ -32070,9 +31117,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1333, "type": "uint256", "value": "remainder" @@ -32096,17 +31141,13 @@ { "attributes": { "argumentTypes": null, - "arguments": [ - null - ], + "arguments": [null], "isConstant": false, "isLValue": false, "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -32114,24 +31155,18 @@ "children": [ { "attributes": { - "argumentTypes": [ - null - ], + "argumentTypes": [null], "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, - "names": [ - "value" - ], + "names": ["value"], "type": "function () payable external" }, "children": [ { "attributes": { - "argumentTypes": [ - null - ], + "argumentTypes": [null], "isConstant": false, "isLValue": false, "isPure": false, @@ -32149,9 +31184,7 @@ "isPure": true, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "contract WETH", "type_conversion": true @@ -32165,9 +31198,7 @@ "typeString": "address" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1431, "type": "type(contract WETH)", "value": "WETH" @@ -32179,9 +31210,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 365, "type": "address", "value": "WETHAddress" @@ -32230,9 +31259,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -15, "type": "msg", "value": "msg" @@ -32249,9 +31276,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1333, "type": "uint256", "value": "remainder" @@ -32290,9 +31315,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -32334,9 +31357,7 @@ "typeString": "uint32" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 395, "type": "function (uint8,uint8,uint8,bytes32,bytes32,bytes32,uint256,uint32)", "value": "LogTokensLocked" @@ -32348,9 +31369,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1318, "type": "uint8", "value": "target_chain" @@ -32362,9 +31381,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 362, "type": "uint8", "value": "CHAIN_ID" @@ -32398,9 +31415,7 @@ "isPure": true, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes32", "type_conversion": true @@ -32443,9 +31458,7 @@ "isPure": true, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": true @@ -32483,9 +31496,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 365, "type": "address", "value": "WETHAddress" @@ -32512,9 +31523,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes32", "type_conversion": true @@ -32557,9 +31566,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": true @@ -32609,9 +31616,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -15, "type": "msg", "value": "msg" @@ -32638,9 +31643,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1316, "type": "bytes32", "value": "recipient" @@ -32652,9 +31655,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1343, "type": "uint256", "value": "transfer_amount" @@ -32666,9 +31667,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1320, "type": "uint32", "value": "nonce" @@ -32703,9 +31702,7 @@ "implemented": true, "isConstructor": false, "kind": "fallback", - "modifiers": [ - null - ], + "modifiers": [null], "name": "", "overrides": null, "scope": 1420, @@ -32716,9 +31713,7 @@ "children": [ { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 1404, @@ -32727,9 +31722,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 1405, @@ -32748,9 +31741,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -32764,10 +31755,7 @@ "typeString": "literal_string \"please use lockETH to transfer ETH to Solana\"" } ], - "overloadedDeclarations": [ - -19, - -19 - ], + "overloadedDeclarations": [-19, -19], "referencedDeclaration": -19, "type": "function (string memory) pure", "value": "revert" @@ -32819,9 +31807,7 @@ "implemented": true, "isConstructor": false, "kind": "receive", - "modifiers": [ - null - ], + "modifiers": [null], "name": "", "overrides": null, "scope": 1420, @@ -32832,9 +31818,7 @@ "children": [ { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 1412, @@ -32843,9 +31827,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 1413, @@ -32864,9 +31846,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -32880,10 +31860,7 @@ "typeString": "literal_string \"please use lockETH to transfer ETH to Solana\"" } ], - "overloadedDeclarations": [ - -19, - -19 - ], + "overloadedDeclarations": [-19, -19], "referencedDeclaration": -19, "type": "function (string memory) pure", "value": "revert" @@ -32937,16 +31914,11 @@ { "attributes": { "abstract": false, - "contractDependencies": [ - 3086 - ], + "contractDependencies": [3086], "contractKind": "interface", "documentation": null, "fullyImplemented": false, - "linearizedBaseContracts": [ - 1431, - 3086 - ], + "linearizedBaseContracts": [1431, 3086], "name": "WETH", "scope": 1432 }, @@ -32980,9 +31952,7 @@ "implemented": false, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "deposit", "overrides": null, "scope": 1431, @@ -32993,9 +31963,7 @@ "children": [ { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 1423, @@ -33004,9 +31972,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 1424, @@ -33026,9 +31992,7 @@ "implemented": false, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "withdraw", "overrides": null, "scope": 1431, @@ -33074,9 +32038,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 1429, @@ -33134,4 +32096,4 @@ "methods": {}, "version": 1 } -} \ No newline at end of file +} diff --git a/packages/bridge/contracts/Wormhole.json b/packages/bridge-sdk/contracts/Wormhole.json similarity index 96% rename from packages/bridge/contracts/Wormhole.json rename to packages/bridge-sdk/contracts/Wormhole.json index 140eb0c..410f7b1 100644 --- a/packages/bridge/contracts/Wormhole.json +++ b/packages/bridge-sdk/contracts/Wormhole.json @@ -399,12 +399,8 @@ "ast": { "absolutePath": "/Users/bartosz.lipinski/Workspace/wormhole/ethereum/contracts/Wormhole.sol", "exportedSymbols": { - "WETH": [ - 1431 - ], - "Wormhole": [ - 1420 - ] + "WETH": [1431], + "Wormhole": [1420] }, "id": 1432, "license": "Apache 2", @@ -412,21 +408,13 @@ "nodes": [ { "id": 335, - "literals": [ - "solidity", - "^", - "0.6", - ".0" - ], + "literals": ["solidity", "^", "0.6", ".0"], "nodeType": "PragmaDirective", "src": "64:23:1" }, { "id": 336, - "literals": [ - "experimental", - "ABIEncoderV2" - ], + "literals": ["experimental", "ABIEncoderV2"], "nodeType": "PragmaDirective", "src": "88:33:1" }, @@ -529,17 +517,12 @@ "src": "484:15:1" } ], - "contractDependencies": [ - 3658 - ], + "contractDependencies": [3658], "contractKind": "contract", "documentation": null, "fullyImplemented": true, "id": 1420, - "linearizedBaseContracts": [ - 1420, - 3658 - ], + "linearizedBaseContracts": [1420, 3658], "name": "Wormhole", "nodeType": "ContractDefinition", "nodes": [ @@ -2113,9 +2096,7 @@ "src": "2673:566:1", "statements": [ { - "assignments": [ - 476 - ], + "assignments": [476], "declarations": [ { "constant": false, @@ -2374,10 +2355,7 @@ "id": 509, "name": "revert", "nodeType": "Identifier", - "overloadedDeclarations": [ - -19, - -19 - ], + "overloadedDeclarations": [-19, -19], "referencedDeclaration": -19, "src": "3112:6:1", "typeDescriptions": { @@ -2594,10 +2572,7 @@ "id": 485, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "2813:7:1", "typeDescriptions": { @@ -3099,10 +3074,7 @@ "id": 540, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "3597:7:1", "typeDescriptions": { @@ -3250,9 +3222,7 @@ "src": "3714:47:1" }, { - "assignments": [ - 558 - ], + "assignments": [558], "declarations": [ { "constant": false, @@ -3359,9 +3329,7 @@ "src": "3772:36:1" }, { - "assignments": [ - 565 - ], + "assignments": [565], "declarations": [ { "constant": false, @@ -3924,10 +3892,7 @@ "id": 596, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "4053:7:1", "typeDescriptions": { @@ -3955,9 +3920,7 @@ "src": "4053:67:1" }, { - "assignments": [ - 606 - ], + "assignments": [606], "declarations": [ { "constant": false, @@ -4169,10 +4132,7 @@ "id": 612, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "4219:7:1", "typeDescriptions": { @@ -4398,10 +4358,7 @@ "id": 621, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "4290:7:1", "typeDescriptions": { @@ -4761,10 +4718,7 @@ "id": 635, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "4517:7:1", "typeDescriptions": { @@ -4792,9 +4746,7 @@ "src": "4517:87:1" }, { - "assignments": [ - 657 - ], + "assignments": [657], "declarations": [ { "constant": false, @@ -4870,9 +4822,7 @@ "src": "4686:465:1", "statements": [ { - "assignments": [ - 672 - ], + "assignments": [672], "declarations": [ { "constant": false, @@ -5129,10 +5079,7 @@ "id": 682, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "4751:7:1", "typeDescriptions": { @@ -5254,9 +5201,7 @@ "src": "4831:25:1" }, { - "assignments": [ - 697 - ], + "assignments": [697], "declarations": [ { "constant": false, @@ -5432,9 +5377,7 @@ "src": "4871:37:1" }, { - "assignments": [ - 708 - ], + "assignments": [708], "declarations": [ { "constant": false, @@ -5610,9 +5553,7 @@ "src": "4922:38:1" }, { - "assignments": [ - 719 - ], + "assignments": [719], "declarations": [ { "constant": false, @@ -6067,10 +6008,7 @@ "id": 733, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "5043:7:1", "typeDescriptions": { @@ -6146,9 +6084,7 @@ }, "id": 750, "initializationExpression": { - "assignments": [ - 662 - ], + "assignments": [662], "declarations": [ { "constant": false, @@ -6757,9 +6693,7 @@ "src": "5353:859:1", "statements": [ { - "assignments": [ - 787 - ], + "assignments": [787], "declarations": [ { "constant": false, @@ -6984,10 +6918,7 @@ "id": 793, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "5421:7:1", "typeDescriptions": { @@ -7015,9 +6946,7 @@ "src": "5421:94:1" }, { - "assignments": [ - 803 - ], + "assignments": [803], "declarations": [ { "constant": false, @@ -7124,9 +7053,7 @@ "src": "5525:27:1" }, { - "assignments": [ - 813 - ], + "assignments": [813], "declarations": [ { "constant": false, @@ -7250,9 +7177,7 @@ "src": "5655:103:1", "statements": [ { - "assignments": [ - 831 - ], + "assignments": [831], "declarations": [ { "constant": false, @@ -7550,9 +7475,7 @@ }, "id": 848, "initializationExpression": { - "assignments": [ - 821 - ], + "assignments": [821], "declarations": [ { "constant": false, @@ -7643,9 +7566,7 @@ "src": "5624:134:1" }, { - "assignments": [ - 850 - ], + "assignments": [850], "declarations": [ { "constant": false, @@ -7740,9 +7661,7 @@ "src": "5828:43:1" }, { - "assignments": [ - 858 - ], + "assignments": [858], "declarations": [ { "constant": false, @@ -8245,9 +8164,7 @@ "src": "6266:1644:1", "statements": [ { - "assignments": [ - 895 - ], + "assignments": [895], "declarations": [ { "constant": false, @@ -8354,9 +8271,7 @@ "src": "6319:36:1" }, { - "assignments": [ - 902 - ], + "assignments": [902], "declarations": [ { "constant": false, @@ -8463,9 +8378,7 @@ "src": "6366:36:1" }, { - "assignments": [ - 909 - ], + "assignments": [909], "declarations": [ { "constant": false, @@ -8610,9 +8523,7 @@ "src": "6521:48:1" }, { - "assignments": [ - 918 - ], + "assignments": [918], "declarations": [ { "constant": false, @@ -8719,9 +8630,7 @@ "src": "6580:36:1" }, { - "assignments": [ - 925 - ], + "assignments": [925], "declarations": [ { "constant": false, @@ -8909,10 +8818,7 @@ "id": 931, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "6727:7:1", "typeDescriptions": { @@ -9021,10 +8927,7 @@ "id": 938, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "6816:7:1", "typeDescriptions": { @@ -9103,9 +9006,7 @@ "src": "7514:390:1", "statements": [ { - "assignments": [ - 1005 - ], + "assignments": [1005], "declarations": [ { "constant": false, @@ -9250,9 +9151,7 @@ "src": "7528:47:1" }, { - "assignments": [ - 1014 - ], + "assignments": [1014], "declarations": [ { "constant": false, @@ -9791,9 +9690,7 @@ "src": "6918:590:1", "statements": [ { - "assignments": [ - 949 - ], + "assignments": [949], "declarations": [ { "constant": false, @@ -9900,9 +9797,7 @@ "src": "6932:42:1" }, { - "assignments": [ - 956 - ], + "assignments": [956], "declarations": [ { "constant": false, @@ -10058,9 +9953,7 @@ "src": "6988:74:1" }, { - "assignments": [ - 966 - ], + "assignments": [966], "declarations": [ { "constant": false, @@ -10245,9 +10138,7 @@ "src": "7248:179:1", "statements": [ { - "assignments": [ - 978 - ], + "assignments": [978], "declarations": [ { "constant": false, @@ -10682,9 +10573,7 @@ "src": "8047:808:1", "statements": [ { - "assignments": [ - 1065 - ], + "assignments": [1065], "declarations": [ { "constant": false, @@ -11558,10 +11447,7 @@ "id": 1111, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "9067:7:1", "typeDescriptions": { @@ -11589,9 +11475,7 @@ "src": "9067:72:1" }, { - "assignments": [ - 1119 - ], + "assignments": [1119], "declarations": [ { "constant": false, @@ -11640,9 +11524,7 @@ "src": "9150:28:1" }, { - "assignments": [ - 1123 - ], + "assignments": [1123], "declarations": [ { "constant": false, @@ -11679,9 +11561,7 @@ "src": "9188:21:1" }, { - "assignments": [ - 1126 - ], + "assignments": [1126], "declarations": [ { "constant": false, @@ -11847,9 +11727,7 @@ "src": "9496:1091:1", "statements": [ { - "assignments": [ - 1163 - ], + "assignments": [1163], "declarations": [ { "constant": false, @@ -12242,9 +12120,7 @@ "src": "9586:65:1" }, { - "assignments": [ - 1188 - ], + "assignments": [1188], "declarations": [ { "constant": false, @@ -12590,9 +12466,7 @@ "src": "10060:326:1", "statements": [ { - "assignments": [ - 1210 - ], + "assignments": [1210], "declarations": [ { "constant": false, @@ -13585,10 +13459,7 @@ "id": 1255, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "10400:7:1", "typeDescriptions": { @@ -14232,10 +14103,7 @@ "id": 1288, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "10636:7:1", "typeDescriptions": { @@ -14855,10 +14723,7 @@ "id": 1325, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "10980:7:1", "typeDescriptions": { @@ -14886,9 +14751,7 @@ "src": "10980:72:1" }, { - "assignments": [ - 1333 - ], + "assignments": [1333], "declarations": [ { "constant": false, @@ -15048,9 +14911,7 @@ "src": "11063:42:1" }, { - "assignments": [ - 1343 - ], + "assignments": [1343], "declarations": [ { "constant": false, @@ -15296,10 +15157,7 @@ "id": 1352, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "11173:7:1", "typeDescriptions": { @@ -15490,9 +15348,7 @@ "isLValue": false, "isPure": false, "lValueRequested": false, - "names": [ - "value" - ], + "names": ["value"], "nodeType": "FunctionCallOptions", "options": [ { @@ -16142,10 +15998,7 @@ "id": 1406, "name": "revert", "nodeType": "Identifier", - "overloadedDeclarations": [ - -19, - -19 - ], + "overloadedDeclarations": [-19, -19], "referencedDeclaration": -19, "src": "11641:6:1", "typeDescriptions": { @@ -16239,10 +16092,7 @@ "id": 1414, "name": "revert", "nodeType": "Identifier", - "overloadedDeclarations": [ - -19, - -19 - ], + "overloadedDeclarations": [-19, -19], "referencedDeclaration": -19, "src": "11731:6:1", "typeDescriptions": { @@ -16323,17 +16173,12 @@ "src": "11810:6:1" } ], - "contractDependencies": [ - 3086 - ], + "contractDependencies": [3086], "contractKind": "interface", "documentation": null, "fullyImplemented": false, "id": 1431, - "linearizedBaseContracts": [ - 1431, - 3086 - ], + "linearizedBaseContracts": [1431, 3086], "name": "WETH", "nodeType": "ContractDefinition", "nodes": [ @@ -16435,24 +16280,15 @@ "attributes": { "absolutePath": "/Users/bartosz.lipinski/Workspace/wormhole/ethereum/contracts/Wormhole.sol", "exportedSymbols": { - "WETH": [ - 1431 - ], - "Wormhole": [ - 1420 - ] + "WETH": [1431], + "Wormhole": [1420] }, "license": "Apache 2" }, "children": [ { "attributes": { - "literals": [ - "solidity", - "^", - "0.6", - ".0" - ] + "literals": ["solidity", "^", "0.6", ".0"] }, "id": 335, "name": "PragmaDirective", @@ -16460,10 +16296,7 @@ }, { "attributes": { - "literals": [ - "experimental", - "ABIEncoderV2" - ] + "literals": ["experimental", "ABIEncoderV2"] }, "id": 336, "name": "PragmaDirective", @@ -16475,9 +16308,7 @@ "absolutePath": "@openzeppelin/contracts/token/ERC20/ERC20.sol", "file": "@openzeppelin/contracts/token/ERC20/ERC20.sol", "scope": 1432, - "symbolAliases": [ - null - ], + "symbolAliases": [null], "unitAlias": "" }, "id": 337, @@ -16490,9 +16321,7 @@ "absolutePath": "@openzeppelin/contracts/token/ERC20/IERC20.sol", "file": "@openzeppelin/contracts/token/ERC20/IERC20.sol", "scope": 1432, - "symbolAliases": [ - null - ], + "symbolAliases": [null], "unitAlias": "" }, "id": 338, @@ -16505,9 +16334,7 @@ "absolutePath": "@openzeppelin/contracts/token/ERC20/SafeERC20.sol", "file": "@openzeppelin/contracts/token/ERC20/SafeERC20.sol", "scope": 1432, - "symbolAliases": [ - null - ], + "symbolAliases": [null], "unitAlias": "" }, "id": 339, @@ -16520,9 +16347,7 @@ "absolutePath": "@openzeppelin/contracts/math/SafeMath.sol", "file": "@openzeppelin/contracts/math/SafeMath.sol", "scope": 1432, - "symbolAliases": [ - null - ], + "symbolAliases": [null], "unitAlias": "" }, "id": 340, @@ -16535,9 +16360,7 @@ "absolutePath": "@openzeppelin/contracts/utils/ReentrancyGuard.sol", "file": "@openzeppelin/contracts/utils/ReentrancyGuard.sol", "scope": 1432, - "symbolAliases": [ - null - ], + "symbolAliases": [null], "unitAlias": "" }, "id": 341, @@ -16550,9 +16373,7 @@ "absolutePath": "/Users/bartosz.lipinski/Workspace/wormhole/ethereum/contracts/BytesLib.sol", "file": "./BytesLib.sol", "scope": 1432, - "symbolAliases": [ - null - ], + "symbolAliases": [null], "unitAlias": "" }, "id": 342, @@ -16565,9 +16386,7 @@ "absolutePath": "/Users/bartosz.lipinski/Workspace/wormhole/ethereum/contracts/WrappedAsset.sol", "file": "./WrappedAsset.sol", "scope": 1432, - "symbolAliases": [ - null - ], + "symbolAliases": [null], "unitAlias": "" }, "id": 343, @@ -16577,16 +16396,11 @@ { "attributes": { "abstract": false, - "contractDependencies": [ - 3658 - ], + "contractDependencies": [3658], "contractKind": "contract", "documentation": null, "fullyImplemented": true, - "linearizedBaseContracts": [ - 1420, - 3658 - ], + "linearizedBaseContracts": [1420, 3658], "name": "Wormhole", "scope": 1432 }, @@ -17707,9 +17521,7 @@ "implemented": true, "isConstructor": true, "kind": "constructor", - "modifiers": [ - null - ], + "modifiers": [null], "name": "", "overrides": null, "scope": 1420, @@ -17814,9 +17626,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 436, @@ -17851,9 +17661,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 412, "type": "mapping(uint32 => struct Wormhole.GuardianSet storage ref)", "value": "guardian_sets" @@ -17887,9 +17695,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 430, "type": "struct Wormhole.GuardianSet memory", "value": "initial_guardian_set" @@ -17924,9 +17730,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 414, "type": "uint32", "value": "guardian_set_index" @@ -17978,9 +17782,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 416, "type": "uint32", "value": "guardian_set_expirity" @@ -17992,9 +17794,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 434, "type": "uint32", "value": "_guardian_set_expirity" @@ -18029,9 +17829,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 359, "type": "address", "value": "wrappedAssetMaster" @@ -18043,9 +17841,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 432, "type": "address", "value": "wrapped_asset_master" @@ -18081,9 +17877,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "getGuardianSet", "overrides": null, "scope": 1420, @@ -18184,9 +17978,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 412, "type": "mapping(uint32 => struct Wormhole.GuardianSet storage ref)", "value": "guardian_sets" @@ -18198,9 +17990,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 458, "type": "uint32", "value": "idx" @@ -18281,9 +18071,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 474, @@ -18298,9 +18086,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3657, "type": "modifier ()", "value": "nonReentrant" @@ -18318,9 +18104,7 @@ "children": [ { "attributes": { - "assignments": [ - 476 - ] + "assignments": [476] }, "children": [ { @@ -18361,9 +18145,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "struct Wormhole.ParsedVAA memory", "type_conversion": false @@ -18377,9 +18159,7 @@ "typeString": "bytes calldata" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 781, "type": "function (bytes calldata) view returns (struct Wormhole.ParsedVAA memory)", "value": "parseAndVerifyVAA" @@ -18391,9 +18171,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 470, "type": "bytes calldata", "value": "vaa" @@ -18444,9 +18222,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 476, "type": "struct Wormhole.ParsedVAA memory", "value": "parsed_vaa" @@ -18494,9 +18270,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -18514,10 +18288,7 @@ "typeString": "literal_string \"only the current guardian set can change the guardian set\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -18556,9 +18327,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 476, "type": "struct Wormhole.ParsedVAA memory", "value": "parsed_vaa" @@ -18575,9 +18344,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 414, "type": "uint32", "value": "guardian_set_index" @@ -18628,9 +18395,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -18644,9 +18409,7 @@ "typeString": "bytes memory" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 889, "type": "function (bytes memory)", "value": "vaaUpdateGuardianSet" @@ -18670,9 +18433,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 476, "type": "struct Wormhole.ParsedVAA memory", "value": "parsed_vaa" @@ -18733,9 +18494,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 476, "type": "struct Wormhole.ParsedVAA memory", "value": "parsed_vaa" @@ -18783,9 +18542,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -18799,9 +18556,7 @@ "typeString": "bytes memory" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1051, "type": "function (bytes memory)", "value": "vaaTransfer" @@ -18825,9 +18580,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 476, "type": "struct Wormhole.ParsedVAA memory", "value": "parsed_vaa" @@ -18868,9 +18621,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -18884,10 +18635,7 @@ "typeString": "literal_string \"invalid VAA action\"" } ], - "overloadedDeclarations": [ - -19, - -19 - ], + "overloadedDeclarations": [-19, -19], "referencedDeclaration": -19, "type": "function (string memory) pure", "value": "revert" @@ -18964,9 +18712,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 420, "type": "mapping(bytes32 => bool)", "value": "consumedVAAs" @@ -18990,9 +18736,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 476, "type": "struct Wormhole.ParsedVAA memory", "value": "parsed_vaa" @@ -19055,9 +18799,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "parseAndVerifyVAA", "overrides": null, "scope": 1420, @@ -19168,9 +18910,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 529, "type": "struct Wormhole.ParsedVAA memory", "value": "parsed_vaa" @@ -19192,9 +18932,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint8", "type_conversion": false @@ -19220,9 +18958,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 526, "type": "bytes calldata", "value": "vaa" @@ -19278,9 +19014,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -19298,10 +19032,7 @@ "typeString": "literal_string \"VAA version incompatible\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -19340,9 +19071,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 529, "type": "struct Wormhole.ParsedVAA memory", "value": "parsed_vaa" @@ -19433,9 +19162,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 529, "type": "struct Wormhole.ParsedVAA memory", "value": "parsed_vaa" @@ -19457,9 +19184,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint32", "type_conversion": false @@ -19485,9 +19210,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 526, "type": "bytes calldata", "value": "vaa" @@ -19535,9 +19258,7 @@ }, { "attributes": { - "assignments": [ - 558 - ] + "assignments": [558] }, "children": [ { @@ -19576,9 +19297,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint8", "type_conversion": false @@ -19604,9 +19323,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 526, "type": "bytes calldata", "value": "vaa" @@ -19649,9 +19366,7 @@ }, { "attributes": { - "assignments": [ - 565 - ] + "assignments": [565] }, "children": [ { @@ -19749,9 +19464,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 558, "type": "uint256", "value": "len_signers" @@ -19803,9 +19516,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 529, "type": "struct Wormhole.ParsedVAA memory", "value": "parsed_vaa" @@ -19827,9 +19538,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint32", "type_conversion": false @@ -19855,9 +19564,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 526, "type": "bytes calldata", "value": "vaa" @@ -19874,9 +19581,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 565, "type": "uint256", "value": "offset" @@ -19928,9 +19633,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 529, "type": "struct Wormhole.ParsedVAA memory", "value": "parsed_vaa" @@ -19952,9 +19655,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes32", "type_conversion": false @@ -19968,9 +19669,7 @@ "typeString": "bytes memory" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -8, "type": "function (bytes memory) pure returns (bytes32)", "value": "keccak256" @@ -19987,9 +19686,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes memory", "type_conversion": false @@ -20019,9 +19716,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 526, "type": "bytes calldata", "value": "vaa" @@ -20038,9 +19733,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 565, "type": "uint256", "value": "offset" @@ -20079,9 +19772,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 526, "type": "bytes calldata", "value": "vaa" @@ -20098,9 +19789,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 565, "type": "uint256", "value": "offset" @@ -20144,9 +19833,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -20164,10 +19851,7 @@ "typeString": "literal_string \"VAA was already executed\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -20201,9 +19885,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 420, "type": "mapping(bytes32 => bool)", "value": "consumedVAAs" @@ -20227,9 +19909,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 529, "type": "struct Wormhole.ParsedVAA memory", "value": "parsed_vaa" @@ -20282,9 +19962,7 @@ }, { "attributes": { - "assignments": [ - 606 - ] + "assignments": [606] }, "children": [ { @@ -20330,9 +20008,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 412, "type": "mapping(uint32 => struct Wormhole.GuardianSet storage ref)", "value": "guardian_sets" @@ -20356,9 +20032,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 529, "type": "struct Wormhole.ParsedVAA memory", "value": "parsed_vaa" @@ -20392,9 +20066,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -20412,10 +20084,7 @@ "typeString": "literal_string \"invalid guardian set\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -20466,9 +20135,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 606, "type": "struct Wormhole.GuardianSet memory", "value": "guardian_set" @@ -20546,9 +20213,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -20566,10 +20231,7 @@ "typeString": "literal_string \"guardian set has expired\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -20623,9 +20285,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 606, "type": "struct Wormhole.GuardianSet memory", "value": "guardian_set" @@ -20691,9 +20351,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 606, "type": "struct Wormhole.GuardianSet memory", "value": "guardian_set" @@ -20722,9 +20380,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -4, "type": "block", "value": "block" @@ -20785,9 +20441,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -20805,10 +20459,7 @@ "typeString": "literal_string \"no quorum\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -21100,9 +20751,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 558, "type": "uint256", "value": "len_signers" @@ -21145,9 +20794,7 @@ }, { "attributes": { - "assignments": [ - 657 - ] + "assignments": [657] }, "children": [ { @@ -21221,9 +20868,7 @@ "children": [ { "attributes": { - "assignments": [ - 662 - ] + "assignments": [662] }, "children": [ { @@ -21294,9 +20939,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 662, "type": "uint256", "value": "i" @@ -21308,9 +20951,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 558, "type": "uint256", "value": "len_signers" @@ -21341,9 +20982,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 662, "type": "uint256", "value": "i" @@ -21366,9 +21005,7 @@ "children": [ { "attributes": { - "assignments": [ - 672 - ] + "assignments": [672] }, "children": [ { @@ -21407,9 +21044,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint8", "type_conversion": false @@ -21435,9 +21070,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 526, "type": "bytes calldata", "value": "vaa" @@ -21501,9 +21134,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 662, "type": "uint256", "value": "i" @@ -21559,9 +21190,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -21579,10 +21208,7 @@ "typeString": "literal_string \"signature indices must be ascending\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -21609,9 +21235,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 672, "type": "uint8", "value": "index" @@ -21623,9 +21247,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 657, "type": "int16", "value": "last_index" @@ -21682,9 +21304,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 657, "type": "int16", "value": "last_index" @@ -21701,9 +21321,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "int16", "type_conversion": true @@ -21741,9 +21359,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 672, "type": "uint8", "value": "index" @@ -21769,9 +21385,7 @@ }, { "attributes": { - "assignments": [ - 697 - ] + "assignments": [697] }, "children": [ { @@ -21810,9 +21424,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes32", "type_conversion": false @@ -21838,9 +21450,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 526, "type": "bytes calldata", "value": "vaa" @@ -21904,9 +21514,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 662, "type": "uint256", "value": "i" @@ -21954,9 +21562,7 @@ }, { "attributes": { - "assignments": [ - 708 - ] + "assignments": [708] }, "children": [ { @@ -21995,9 +21601,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes32", "type_conversion": false @@ -22023,9 +21627,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 526, "type": "bytes calldata", "value": "vaa" @@ -22089,9 +21691,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 662, "type": "uint256", "value": "i" @@ -22139,9 +21739,7 @@ }, { "attributes": { - "assignments": [ - 719 - ] + "assignments": [719] }, "children": [ { @@ -22180,9 +21778,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint8", "type_conversion": false @@ -22208,9 +21804,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 526, "type": "bytes calldata", "value": "vaa" @@ -22274,9 +21868,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 662, "type": "uint256", "value": "i" @@ -22338,9 +21930,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 719, "type": "uint8", "value": "v" @@ -22386,9 +21976,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -22406,10 +21994,7 @@ "typeString": "literal_string \"VAA signature invalid\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -22441,9 +22026,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address", "type_conversion": false @@ -22469,9 +22052,7 @@ "typeString": "bytes32" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -6, "type": "function (bytes32,uint8,bytes32,bytes32) pure returns (address)", "value": "ecrecover" @@ -22514,9 +22095,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 719, "type": "uint8", "value": "v" @@ -22528,9 +22107,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 697, "type": "bytes32", "value": "r" @@ -22542,9 +22119,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 708, "type": "bytes32", "value": "s" @@ -22602,9 +22177,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 672, "type": "uint8", "value": "index" @@ -22688,9 +22261,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 529, "type": "struct Wormhole.ParsedVAA memory", "value": "parsed_vaa" @@ -22712,9 +22283,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint8", "type_conversion": false @@ -22740,9 +22309,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 526, "type": "bytes calldata", "value": "vaa" @@ -22774,9 +22341,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 565, "type": "uint256", "value": "offset" @@ -22850,9 +22415,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 529, "type": "struct Wormhole.ParsedVAA memory", "value": "parsed_vaa" @@ -22874,9 +22437,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes memory", "type_conversion": false @@ -22906,9 +22467,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 526, "type": "bytes calldata", "value": "vaa" @@ -22940,9 +22499,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 565, "type": "uint256", "value": "offset" @@ -23003,9 +22560,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 526, "type": "bytes calldata", "value": "vaa" @@ -23048,9 +22603,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 565, "type": "uint256", "value": "offset" @@ -23122,9 +22675,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "vaaUpdateGuardianSet", "overrides": null, "scope": 1420, @@ -23170,9 +22721,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 785, @@ -23183,9 +22732,7 @@ "children": [ { "attributes": { - "assignments": [ - 787 - ] + "assignments": [787] }, "children": [ { @@ -23224,9 +22771,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint32", "type_conversion": false @@ -23252,9 +22797,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 783, "type": "bytes memory", "value": "data" @@ -23305,9 +22848,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -23325,10 +22866,7 @@ "typeString": "literal_string \"index must increase in steps of 1\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -23355,9 +22893,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 787, "type": "uint32", "value": "new_guardian_set_index" @@ -23384,9 +22920,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 414, "type": "uint32", "value": "guardian_set_index" @@ -23451,9 +22985,7 @@ }, { "attributes": { - "assignments": [ - 803 - ] + "assignments": [803] }, "children": [ { @@ -23492,9 +23024,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint8", "type_conversion": false @@ -23520,9 +23050,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 783, "type": "bytes memory", "value": "data" @@ -23565,9 +23093,7 @@ }, { "attributes": { - "assignments": [ - 813 - ] + "assignments": [813] }, "children": [ { @@ -23617,9 +23143,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address[] memory", "type_conversion": false @@ -23669,9 +23193,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 803, "type": "uint8", "value": "len" @@ -23694,9 +23216,7 @@ "children": [ { "attributes": { - "assignments": [ - 821 - ] + "assignments": [821] }, "children": [ { @@ -23767,9 +23287,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 821, "type": "uint256", "value": "i" @@ -23781,9 +23299,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 803, "type": "uint8", "value": "len" @@ -23814,9 +23330,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 821, "type": "uint256", "value": "i" @@ -23839,9 +23353,7 @@ "children": [ { "attributes": { - "assignments": [ - 831 - ] + "assignments": [831] }, "children": [ { @@ -23881,9 +23393,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address", "type_conversion": false @@ -23909,9 +23419,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 783, "type": "bytes memory", "value": "data" @@ -23975,9 +23483,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 821, "type": "uint256", "value": "i" @@ -24049,9 +23555,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 813, "type": "address[] memory", "value": "new_guardians" @@ -24063,9 +23567,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 821, "type": "uint256", "value": "i" @@ -24082,9 +23584,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 831, "type": "address", "value": "addr" @@ -24115,9 +23615,7 @@ }, { "attributes": { - "assignments": [ - 850 - ] + "assignments": [850] }, "children": [ { @@ -24151,9 +23649,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 414, "type": "uint32", "value": "guardian_set_index" @@ -24183,9 +23679,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 414, "type": "uint32", "value": "guardian_set_index" @@ -24197,9 +23691,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 787, "type": "uint32", "value": "new_guardian_set_index" @@ -24220,9 +23712,7 @@ }, { "attributes": { - "assignments": [ - 858 - ] + "assignments": [858] }, "children": [ { @@ -24263,9 +23753,7 @@ "isPure": false, "isStructConstructorCall": true, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "struct Wormhole.GuardianSet memory", "type_conversion": false @@ -24283,9 +23771,7 @@ "typeString": "int_const 0" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 371, "type": "type(struct Wormhole.GuardianSet storage pointer)", "value": "GuardianSet" @@ -24297,9 +23783,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 813, "type": "address[] memory", "value": "new_guardians" @@ -24361,9 +23845,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 412, "type": "mapping(uint32 => struct Wormhole.GuardianSet storage ref)", "value": "guardian_sets" @@ -24375,9 +23857,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 414, "type": "uint32", "value": "guardian_set_index" @@ -24394,9 +23874,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 858, "type": "struct Wormhole.GuardianSet memory", "value": "new_guardian_set" @@ -24453,9 +23931,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 412, "type": "mapping(uint32 => struct Wormhole.GuardianSet storage ref)", "value": "guardian_sets" @@ -24467,9 +23943,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 850, "type": "uint32", "value": "old_guardian_set_index" @@ -24511,9 +23985,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint32", "type_conversion": true @@ -24563,9 +24035,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -4, "type": "block", "value": "block" @@ -24587,9 +24057,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 416, "type": "uint32", "value": "guardian_set_expirity" @@ -24623,9 +24091,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -24643,9 +24109,7 @@ "typeString": "uint32" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 377, "type": "function (uint32,uint32)", "value": "LogGuardianSetChanged" @@ -24657,9 +24121,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 850, "type": "uint32", "value": "old_guardian_set_index" @@ -24671,9 +24133,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 414, "type": "uint32", "value": "guardian_set_index" @@ -24708,9 +24168,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "vaaTransfer", "overrides": null, "scope": 1420, @@ -24756,9 +24214,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 893, @@ -24769,9 +24225,7 @@ "children": [ { "attributes": { - "assignments": [ - 895 - ] + "assignments": [895] }, "children": [ { @@ -24810,9 +24264,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint8", "type_conversion": false @@ -24838,9 +24290,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 891, "type": "bytes memory", "value": "data" @@ -24883,9 +24333,7 @@ }, { "attributes": { - "assignments": [ - 902 - ] + "assignments": [902] }, "children": [ { @@ -24924,9 +24372,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint8", "type_conversion": false @@ -24952,9 +24398,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 891, "type": "bytes memory", "value": "data" @@ -24997,9 +24441,7 @@ }, { "attributes": { - "assignments": [ - 909 - ] + "assignments": [909] }, "children": [ { @@ -25039,9 +24481,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address", "type_conversion": false @@ -25067,9 +24507,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 891, "type": "bytes memory", "value": "data" @@ -25149,9 +24587,7 @@ }, { "attributes": { - "assignments": [ - 918 - ] + "assignments": [918] }, "children": [ { @@ -25190,9 +24626,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint8", "type_conversion": false @@ -25218,9 +24652,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 891, "type": "bytes memory", "value": "data" @@ -25263,9 +24695,7 @@ }, { "attributes": { - "assignments": [ - 925 - ] + "assignments": [925] }, "children": [ { @@ -25304,9 +24734,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -25332,9 +24760,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 891, "type": "bytes memory", "value": "data" @@ -25385,9 +24811,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -25405,10 +24829,7 @@ "typeString": "literal_string \"same chain transfers are not supported\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -25435,9 +24856,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 895, "type": "uint8", "value": "source_chain" @@ -25449,9 +24868,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 902, "type": "uint8", "value": "target_chain" @@ -25502,9 +24919,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -25522,10 +24937,7 @@ "typeString": "literal_string \"transfer must be incoming\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -25552,9 +24964,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 902, "type": "uint8", "value": "target_chain" @@ -25566,9 +24976,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 362, "type": "uint8", "value": "CHAIN_ID" @@ -25629,9 +25037,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 918, "type": "uint8", "value": "token_chain" @@ -25643,9 +25049,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 362, "type": "uint8", "value": "CHAIN_ID" @@ -25663,9 +25067,7 @@ "children": [ { "attributes": { - "assignments": [ - 949 - ] + "assignments": [949] }, "children": [ { @@ -25704,9 +25106,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes32", "type_conversion": false @@ -25732,9 +25132,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 891, "type": "bytes memory", "value": "data" @@ -25777,9 +25175,7 @@ }, { "attributes": { - "assignments": [ - 956 - ] + "assignments": [956] }, "children": [ { @@ -25818,9 +25214,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes32", "type_conversion": false @@ -25834,9 +25228,7 @@ "typeString": "bytes memory" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -8, "type": "function (bytes memory) pure returns (bytes32)", "value": "keccak256" @@ -25853,9 +25245,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes memory", "type_conversion": false @@ -25885,9 +25275,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -1, "type": "abi", "value": "abi" @@ -25904,9 +25292,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 918, "type": "uint8", "value": "token_chain" @@ -25918,9 +25304,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 949, "type": "bytes32", "value": "token_address" @@ -25946,9 +25330,7 @@ }, { "attributes": { - "assignments": [ - 966 - ] + "assignments": [966] }, "children": [ { @@ -25993,9 +25375,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 424, "type": "mapping(bytes32 => address)", "value": "wrappedAssets" @@ -26007,9 +25387,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 956, "type": "bytes32", "value": "asset_id" @@ -26051,9 +25429,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 966, "type": "address", "value": "wrapped_asset" @@ -26070,9 +25446,7 @@ "isPure": true, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": true @@ -26138,9 +25512,7 @@ "children": [ { "attributes": { - "assignments": [ - 978 - ] + "assignments": [978] }, "children": [ { @@ -26179,9 +25551,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint8", "type_conversion": false @@ -26266,9 +25636,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 966, "type": "address", "value": "wrapped_asset" @@ -26285,9 +25653,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address", "type_conversion": false @@ -26415,9 +25781,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -26452,9 +25816,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "contract WrappedAsset", "type_conversion": true @@ -26468,9 +25830,7 @@ "typeString": "address" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2147, "type": "type(contract WrappedAsset)", "value": "WrappedAsset" @@ -26482,9 +25842,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 966, "type": "address", "value": "wrapped_asset" @@ -26506,9 +25864,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 909, "type": "address", "value": "target_address" @@ -26520,9 +25876,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 925, "type": "uint256", "value": "amount" @@ -26550,9 +25904,7 @@ "children": [ { "attributes": { - "assignments": [ - 1005 - ] + "assignments": [1005] }, "children": [ { @@ -26592,9 +25944,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address", "type_conversion": false @@ -26620,9 +25970,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 891, "type": "bytes memory", "value": "data" @@ -26702,9 +26050,7 @@ }, { "attributes": { - "assignments": [ - 1014 - ] + "assignments": [1014] }, "children": [ { @@ -26738,17 +26084,13 @@ { "attributes": { "argumentTypes": null, - "arguments": [ - null - ], + "arguments": [null], "isConstant": false, "isLValue": false, "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint8", "type_conversion": false @@ -26756,9 +26098,7 @@ "children": [ { "attributes": { - "argumentTypes": [ - null - ], + "argumentTypes": [null], "isConstant": false, "isLValue": false, "isPure": false, @@ -26776,9 +26116,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "contract ERC20", "type_conversion": true @@ -26792,9 +26130,7 @@ "typeString": "address" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3008, "type": "type(contract ERC20)", "value": "ERC20" @@ -26806,9 +26142,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1005, "type": "address", "value": "token_address" @@ -26860,9 +26194,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1014, "type": "uint8", "value": "decimals" @@ -26911,9 +26243,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 925, "type": "uint256", "value": "amount" @@ -26930,9 +26260,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -27014,9 +26342,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": true @@ -27147,9 +26473,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -27184,9 +26508,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "contract IERC20", "type_conversion": true @@ -27200,9 +26522,7 @@ "typeString": "address" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3086, "type": "type(contract IERC20)", "value": "IERC20" @@ -27214,9 +26534,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1005, "type": "address", "value": "token_address" @@ -27238,9 +26556,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 909, "type": "address", "value": "target_address" @@ -27252,9 +26568,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 925, "type": "uint256", "value": "amount" @@ -27299,9 +26613,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "deployWrappedAsset", "overrides": null, "scope": 1420, @@ -27469,9 +26781,7 @@ "children": [ { "attributes": { - "assignments": [ - 1065 - ] + "assignments": [1065] }, "children": [ { @@ -27510,9 +26820,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes20", "type_conversion": true @@ -27550,9 +26858,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 359, "type": "address", "value": "wrappedAssetMaster" @@ -27614,9 +26920,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -27655,9 +26959,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "contract WrappedAsset", "type_conversion": true @@ -27671,9 +26973,7 @@ "typeString": "address" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2147, "type": "type(contract WrappedAsset)", "value": "WrappedAsset" @@ -27685,9 +26985,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1062, "type": "address", "value": "asset" @@ -27709,9 +27007,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1055, "type": "uint8", "value": "token_chain" @@ -27723,9 +27019,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1057, "type": "bytes32", "value": "token_address" @@ -27737,9 +27031,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1059, "type": "uint8", "value": "decimals" @@ -27784,9 +27076,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 424, "type": "mapping(bytes32 => address)", "value": "wrappedAssets" @@ -27798,9 +27088,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1053, "type": "bytes32", "value": "seed" @@ -27817,9 +27105,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1062, "type": "address", "value": "asset" @@ -27864,9 +27150,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 428, "type": "mapping(address => bool)", "value": "isWrappedAsset" @@ -27878,9 +27162,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1062, "type": "address", "value": "asset" @@ -28124,9 +27406,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 1110, @@ -28141,9 +27421,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3657, "type": "modifier ()", "value": "nonReentrant" @@ -28169,9 +27447,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -28189,10 +27465,7 @@ "typeString": "literal_string \"must not transfer to the same chain\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -28219,9 +27492,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1102, "type": "uint8", "value": "target_chain" @@ -28233,9 +27504,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 362, "type": "uint8", "value": "CHAIN_ID" @@ -28278,9 +27547,7 @@ }, { "attributes": { - "assignments": [ - 1119 - ] + "assignments": [1119] }, "children": [ { @@ -28314,9 +27581,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 362, "type": "uint8", "value": "CHAIN_ID" @@ -28332,9 +27597,7 @@ }, { "attributes": { - "assignments": [ - 1123 - ], + "assignments": [1123], "initialValue": null }, "children": [ @@ -28373,9 +27636,7 @@ }, { "attributes": { - "assignments": [ - 1126 - ] + "assignments": [1126] }, "children": [ { @@ -28409,17 +27670,13 @@ { "attributes": { "argumentTypes": null, - "arguments": [ - null - ], + "arguments": [null], "isConstant": false, "isLValue": false, "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint8", "type_conversion": false @@ -28427,9 +27684,7 @@ "children": [ { "attributes": { - "argumentTypes": [ - null - ], + "argumentTypes": [null], "isConstant": false, "isLValue": false, "isPure": false, @@ -28447,9 +27702,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "contract ERC20", "type_conversion": true @@ -28463,9 +27716,7 @@ "typeString": "address" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3008, "type": "type(contract ERC20)", "value": "ERC20" @@ -28477,9 +27728,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1096, "type": "address", "value": "asset" @@ -28523,9 +27772,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 428, "type": "mapping(address => bool)", "value": "isWrappedAsset" @@ -28537,9 +27784,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1096, "type": "address", "value": "asset" @@ -28565,9 +27810,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -28602,9 +27845,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "contract WrappedAsset", "type_conversion": true @@ -28618,9 +27859,7 @@ "typeString": "address" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2147, "type": "type(contract WrappedAsset)", "value": "WrappedAsset" @@ -28632,9 +27871,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1096, "type": "address", "value": "asset" @@ -28668,9 +27905,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -15, "type": "msg", "value": "msg" @@ -28687,9 +27922,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1098, "type": "uint256", "value": "amount" @@ -28724,9 +27957,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1119, "type": "uint8", "value": "asset_chain" @@ -28738,17 +27969,13 @@ { "attributes": { "argumentTypes": null, - "arguments": [ - null - ], + "arguments": [null], "isConstant": false, "isLValue": false, "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint8", "type_conversion": false @@ -28756,9 +27983,7 @@ "children": [ { "attributes": { - "argumentTypes": [ - null - ], + "argumentTypes": [null], "isConstant": false, "isLValue": false, "isPure": false, @@ -28776,9 +28001,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "contract WrappedAsset", "type_conversion": true @@ -28858,9 +28081,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1123, "type": "bytes32", "value": "asset_address" @@ -28872,17 +28093,13 @@ { "attributes": { "argumentTypes": null, - "arguments": [ - null - ], + "arguments": [null], "isConstant": false, "isLValue": false, "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes32", "type_conversion": false @@ -28890,9 +28107,7 @@ "children": [ { "attributes": { - "argumentTypes": [ - null - ], + "argumentTypes": [null], "isConstant": false, "isLValue": false, "isPure": false, @@ -28910,9 +28125,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "contract WrappedAsset", "type_conversion": true @@ -28985,9 +28198,7 @@ "children": [ { "attributes": { - "assignments": [ - 1163 - ] + "assignments": [1163] }, "children": [ { @@ -29026,9 +28237,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -29059,9 +28268,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "contract IERC20", "type_conversion": true @@ -29075,9 +28282,7 @@ "typeString": "address" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3086, "type": "type(contract IERC20)", "value": "IERC20" @@ -29089,9 +28294,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1096, "type": "address", "value": "asset" @@ -29118,9 +28321,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": true @@ -29158,9 +28359,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -28, "type": "contract Wormhole", "value": "this" @@ -29194,9 +28393,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -29235,9 +28432,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "contract IERC20", "type_conversion": true @@ -29251,9 +28446,7 @@ "typeString": "address" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3086, "type": "type(contract IERC20)", "value": "IERC20" @@ -29265,9 +28458,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1096, "type": "address", "value": "asset" @@ -29301,9 +28492,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -15, "type": "msg", "value": "msg" @@ -29325,9 +28514,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": true @@ -29365,9 +28552,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -28, "type": "contract Wormhole", "value": "this" @@ -29384,9 +28569,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1098, "type": "uint256", "value": "amount" @@ -29407,9 +28590,7 @@ }, { "attributes": { - "assignments": [ - 1188 - ] + "assignments": [1188] }, "children": [ { @@ -29448,9 +28629,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -29481,9 +28660,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "contract IERC20", "type_conversion": true @@ -29497,9 +28674,7 @@ "typeString": "address" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3086, "type": "type(contract IERC20)", "value": "IERC20" @@ -29511,9 +28686,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1096, "type": "address", "value": "asset" @@ -29540,9 +28713,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": true @@ -29580,9 +28751,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -28, "type": "contract Wormhole", "value": "this" @@ -29622,9 +28791,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1098, "type": "uint256", "value": "amount" @@ -29641,9 +28808,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -29669,9 +28834,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1188, "type": "uint256", "value": "balanceAfter" @@ -29688,9 +28851,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1163, "type": "uint256", "value": "balanceBefore" @@ -29737,9 +28898,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1126, "type": "uint8", "value": "decimals" @@ -29774,9 +28933,7 @@ "children": [ { "attributes": { - "assignments": [ - 1210 - ] + "assignments": [1210] }, "children": [ { @@ -29810,9 +28967,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1098, "type": "uint256", "value": "amount" @@ -29842,9 +28997,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1098, "type": "uint256", "value": "amount" @@ -29861,9 +29014,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -29945,9 +29096,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": true @@ -30066,9 +29215,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1106, "type": "bool", "value": "refund_dust" @@ -30089,9 +29236,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -30126,9 +29271,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "contract IERC20", "type_conversion": true @@ -30216,9 +29359,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -30300,9 +29441,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": true @@ -30439,9 +29578,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1126, "type": "uint8", "value": "decimals" @@ -30497,9 +29634,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -30517,10 +29652,7 @@ "typeString": "literal_string \"bridge balance would exceed maximum\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -30552,9 +29684,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -30636,9 +29766,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": true @@ -30691,17 +29819,13 @@ { "attributes": { "argumentTypes": null, - "arguments": [ - null - ], + "arguments": [null], "isConstant": false, "isLValue": false, "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint8", "type_conversion": false @@ -30825,9 +29949,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 357, "type": "uint64", "value": "MAX_UINT64" @@ -30884,9 +30006,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1123, "type": "bytes32", "value": "asset_address" @@ -30903,9 +30023,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes32", "type_conversion": true @@ -30948,9 +30066,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": true @@ -30988,9 +30104,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1096, "type": "address", "value": "asset" @@ -31039,9 +30153,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -31059,10 +30171,7 @@ "typeString": "literal_string \"truncated amount must not be 0\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -31089,9 +30198,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1098, "type": "uint256", "value": "amount" @@ -31159,9 +30266,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -31203,9 +30308,7 @@ "typeString": "uint32" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 395, "type": "function (uint8,uint8,uint8,bytes32,bytes32,bytes32,uint256,uint32)", "value": "LogTokensLocked" @@ -31217,9 +30320,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1102, "type": "uint8", "value": "target_chain" @@ -31231,9 +30332,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1119, "type": "uint8", "value": "asset_chain" @@ -31245,9 +30344,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1126, "type": "uint8", "value": "decimals" @@ -31259,9 +30356,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1123, "type": "bytes32", "value": "asset_address" @@ -31278,9 +30373,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes32", "type_conversion": true @@ -31323,9 +30416,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": true @@ -31375,9 +30466,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -15, "type": "msg", "value": "msg" @@ -31404,9 +30493,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1100, "type": "bytes32", "value": "recipient" @@ -31418,9 +30505,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1098, "type": "uint256", "value": "amount" @@ -31432,9 +30517,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1104, "type": "uint32", "value": "nonce" @@ -31571,9 +30654,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 1324, @@ -31588,9 +30669,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3657, "type": "modifier ()", "value": "nonReentrant" @@ -31616,9 +30695,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -31636,10 +30713,7 @@ "typeString": "literal_string \"must not transfer to the same chain\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -31666,9 +30740,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1318, "type": "uint8", "value": "target_chain" @@ -31680,9 +30752,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 362, "type": "uint8", "value": "CHAIN_ID" @@ -31725,9 +30795,7 @@ }, { "attributes": { - "assignments": [ - 1333 - ] + "assignments": [1333] }, "children": [ { @@ -31766,9 +30834,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -31806,9 +30872,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -15, "type": "msg", "value": "msg" @@ -31893,9 +30957,7 @@ }, { "attributes": { - "assignments": [ - 1343 - ] + "assignments": [1343] }, "children": [ { @@ -31934,9 +30996,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -31974,9 +31034,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -15, "type": "msg", "value": "msg" @@ -32069,9 +31127,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -32089,10 +31145,7 @@ "typeString": "literal_string \"truncated amount must not be 0\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -32119,9 +31172,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1343, "type": "uint256", "value": "transfer_amount" @@ -32189,9 +31240,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -32229,9 +31278,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -15, "type": "msg", "value": "msg" @@ -32253,9 +31300,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1333, "type": "uint256", "value": "remainder" @@ -32279,17 +31324,13 @@ { "attributes": { "argumentTypes": null, - "arguments": [ - null - ], + "arguments": [null], "isConstant": false, "isLValue": false, "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -32297,24 +31338,18 @@ "children": [ { "attributes": { - "argumentTypes": [ - null - ], + "argumentTypes": [null], "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, - "names": [ - "value" - ], + "names": ["value"], "type": "function () payable external" }, "children": [ { "attributes": { - "argumentTypes": [ - null - ], + "argumentTypes": [null], "isConstant": false, "isLValue": false, "isPure": false, @@ -32332,9 +31367,7 @@ "isPure": true, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "contract WETH", "type_conversion": true @@ -32348,9 +31381,7 @@ "typeString": "address" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1431, "type": "type(contract WETH)", "value": "WETH" @@ -32362,9 +31393,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 365, "type": "address", "value": "WETHAddress" @@ -32413,9 +31442,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -15, "type": "msg", "value": "msg" @@ -32432,9 +31459,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1333, "type": "uint256", "value": "remainder" @@ -32473,9 +31498,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -32517,9 +31540,7 @@ "typeString": "uint32" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 395, "type": "function (uint8,uint8,uint8,bytes32,bytes32,bytes32,uint256,uint32)", "value": "LogTokensLocked" @@ -32531,9 +31552,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1318, "type": "uint8", "value": "target_chain" @@ -32545,9 +31564,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 362, "type": "uint8", "value": "CHAIN_ID" @@ -32581,9 +31598,7 @@ "isPure": true, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes32", "type_conversion": true @@ -32626,9 +31641,7 @@ "isPure": true, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": true @@ -32666,9 +31679,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 365, "type": "address", "value": "WETHAddress" @@ -32695,9 +31706,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes32", "type_conversion": true @@ -32740,9 +31749,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": true @@ -32792,9 +31799,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -15, "type": "msg", "value": "msg" @@ -32821,9 +31826,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1316, "type": "bytes32", "value": "recipient" @@ -32835,9 +31838,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1343, "type": "uint256", "value": "transfer_amount" @@ -32849,9 +31850,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1320, "type": "uint32", "value": "nonce" @@ -32886,9 +31885,7 @@ "implemented": true, "isConstructor": false, "kind": "fallback", - "modifiers": [ - null - ], + "modifiers": [null], "name": "", "overrides": null, "scope": 1420, @@ -32899,9 +31896,7 @@ "children": [ { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 1404, @@ -32910,9 +31905,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 1405, @@ -32931,9 +31924,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -32947,10 +31938,7 @@ "typeString": "literal_string \"please use lockETH to transfer ETH to Solana\"" } ], - "overloadedDeclarations": [ - -19, - -19 - ], + "overloadedDeclarations": [-19, -19], "referencedDeclaration": -19, "type": "function (string memory) pure", "value": "revert" @@ -33002,9 +31990,7 @@ "implemented": true, "isConstructor": false, "kind": "receive", - "modifiers": [ - null - ], + "modifiers": [null], "name": "", "overrides": null, "scope": 1420, @@ -33015,9 +32001,7 @@ "children": [ { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 1412, @@ -33026,9 +32010,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 1413, @@ -33047,9 +32029,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -33063,10 +32043,7 @@ "typeString": "literal_string \"please use lockETH to transfer ETH to Solana\"" } ], - "overloadedDeclarations": [ - -19, - -19 - ], + "overloadedDeclarations": [-19, -19], "referencedDeclaration": -19, "type": "function (string memory) pure", "value": "revert" @@ -33120,16 +32097,11 @@ { "attributes": { "abstract": false, - "contractDependencies": [ - 3086 - ], + "contractDependencies": [3086], "contractKind": "interface", "documentation": null, "fullyImplemented": false, - "linearizedBaseContracts": [ - 1431, - 3086 - ], + "linearizedBaseContracts": [1431, 3086], "name": "WETH", "scope": 1432 }, @@ -33163,9 +32135,7 @@ "implemented": false, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "deposit", "overrides": null, "scope": 1431, @@ -33176,9 +32146,7 @@ "children": [ { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 1423, @@ -33187,9 +32155,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 1424, @@ -33209,9 +32175,7 @@ "implemented": false, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "withdraw", "overrides": null, "scope": 1431, @@ -33257,9 +32221,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 1429, @@ -33298,4 +32260,4 @@ "methods": {}, "version": 1 } -} \ No newline at end of file +} diff --git a/packages/bridge/contracts/WrappedAsset.json b/packages/bridge-sdk/contracts/WrappedAsset.json similarity index 96% rename from packages/bridge/contracts/WrappedAsset.json rename to packages/bridge-sdk/contracts/WrappedAsset.json index a06da0d..451168f 100644 --- a/packages/bridge/contracts/WrappedAsset.json +++ b/packages/bridge-sdk/contracts/WrappedAsset.json @@ -394,9 +394,7 @@ "ast": { "absolutePath": "/Users/bartosz.lipinski/Workspace/wormhole/ethereum/contracts/WrappedAsset.sol", "exportedSymbols": { - "WrappedAsset": [ - 2147 - ] + "WrappedAsset": [2147] }, "id": 2148, "license": "Apache 2", @@ -404,12 +402,7 @@ "nodes": [ { "id": 1433, - "literals": [ - "solidity", - "^", - "0.6", - ".0" - ], + "literals": ["solidity", "^", "0.6", ".0"], "nodeType": "PragmaDirective", "src": "67:23:2" }, @@ -497,19 +490,12 @@ "src": "337:7:2" } ], - "contractDependencies": [ - 3086, - 3618 - ], + "contractDependencies": [3086, 3618], "contractKind": "contract", "documentation": null, "fullyImplemented": true, "id": 2147, - "linearizedBaseContracts": [ - 2147, - 3618, - 3086 - ], + "linearizedBaseContracts": [2147, 3618, 3086], "name": "WrappedAsset", "nodeType": "ContractDefinition", "nodes": [ @@ -702,10 +688,7 @@ "id": 1458, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "565:7:2", "typeDescriptions": { @@ -1252,10 +1235,7 @@ "id": 1497, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "901:7:2", "typeDescriptions": { @@ -1545,10 +1525,7 @@ "id": 1518, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "1083:7:2", "typeDescriptions": { @@ -2402,9 +2379,7 @@ } }, { - "assignments": [ - 1591 - ], + "assignments": [1591], "declarations": [ { "constant": false, @@ -2453,9 +2428,7 @@ "src": "2072:11:2" }, { - "assignments": [ - 1595 - ], + "assignments": [1595], "declarations": [ { "constant": false, @@ -2639,9 +2612,7 @@ "src": "2111:66:2" }, { - "assignments": [ - 1610 - ], + "assignments": [1610], "declarations": [ { "constant": false, @@ -2738,9 +2709,7 @@ "src": "2186:34:2" }, { - "assignments": [ - 1617 - ], + "assignments": [1617], "declarations": [ { "constant": false, @@ -3357,9 +3326,7 @@ "src": "2514:373:2", "statements": [ { - "assignments": [ - 1660 - ], + "assignments": [1660], "declarations": [ { "constant": false, @@ -3413,9 +3380,7 @@ "src": "2524:42:2" }, { - "assignments": [ - 1664 - ], + "assignments": [1664], "declarations": [ { "constant": false, @@ -3464,9 +3429,7 @@ "src": "2576:27:2" }, { - "assignments": [ - 1668 - ], + "assignments": [1668], "declarations": [ { "constant": false, @@ -4354,9 +4317,7 @@ }, "id": 1733, "initializationExpression": { - "assignments": [ - 1680 - ], + "assignments": [1680], "declarations": [ { "constant": false, @@ -4747,9 +4708,7 @@ "visibility": "public" }, { - "baseFunctions": [ - 3017 - ], + "baseFunctions": [3017], "body": { "id": 1767, "nodeType": "Block", @@ -4843,9 +4802,7 @@ "visibility": "public" }, { - "baseFunctions": [ - 3025 - ], + "baseFunctions": [3025], "body": { "id": 1781, "nodeType": "Block", @@ -4996,9 +4953,7 @@ "visibility": "public" }, { - "baseFunctions": [ - 3035 - ], + "baseFunctions": [3035], "body": { "id": 1802, "nodeType": "Block", @@ -5262,9 +5217,7 @@ "visibility": "public" }, { - "baseFunctions": [ - 3045 - ], + "baseFunctions": [3045], "body": { "id": 1820, "nodeType": "Block", @@ -5471,9 +5424,7 @@ "visibility": "public" }, { - "baseFunctions": [ - 3055 - ], + "baseFunctions": [3055], "body": { "id": 1841, "nodeType": "Block", @@ -5737,9 +5688,7 @@ "visibility": "public" }, { - "baseFunctions": [ - 3067 - ], + "baseFunctions": [3067], "body": { "id": 1879, "nodeType": "Block", @@ -7196,10 +7145,7 @@ "id": 1947, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "7663:7:2", "typeDescriptions": { @@ -7361,10 +7307,7 @@ "id": 1957, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "7743:7:2", "typeDescriptions": { @@ -8069,10 +8012,7 @@ "id": 2005, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "8375:7:2", "typeDescriptions": { @@ -8725,10 +8665,7 @@ "id": 2051, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "8996:7:2", "typeDescriptions": { @@ -9403,10 +9340,7 @@ "id": 2100, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "9781:7:2", "typeDescriptions": { @@ -9568,10 +9502,7 @@ "id": 2110, "name": "require", "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "src": "9859:7:2", "typeDescriptions": { @@ -10032,21 +9963,14 @@ "attributes": { "absolutePath": "/Users/bartosz.lipinski/Workspace/wormhole/ethereum/contracts/WrappedAsset.sol", "exportedSymbols": { - "WrappedAsset": [ - 2147 - ] + "WrappedAsset": [2147] }, "license": "Apache 2" }, "children": [ { "attributes": { - "literals": [ - "solidity", - "^", - "0.6", - ".0" - ] + "literals": ["solidity", "^", "0.6", ".0"] }, "id": 1433, "name": "PragmaDirective", @@ -10058,9 +9982,7 @@ "absolutePath": "@openzeppelin/contracts/token/ERC20/IERC20.sol", "file": "@openzeppelin/contracts/token/ERC20/IERC20.sol", "scope": 2148, - "symbolAliases": [ - null - ], + "symbolAliases": [null], "unitAlias": "" }, "id": 1434, @@ -10073,9 +9995,7 @@ "absolutePath": "@openzeppelin/contracts/math/SafeMath.sol", "file": "@openzeppelin/contracts/math/SafeMath.sol", "scope": 2148, - "symbolAliases": [ - null - ], + "symbolAliases": [null], "unitAlias": "" }, "id": 1435, @@ -10088,9 +10008,7 @@ "absolutePath": "@openzeppelin/contracts/utils/Address.sol", "file": "@openzeppelin/contracts/utils/Address.sol", "scope": 2148, - "symbolAliases": [ - null - ], + "symbolAliases": [null], "unitAlias": "" }, "id": 1436, @@ -10103,9 +10021,7 @@ "absolutePath": "@openzeppelin/contracts/GSN/Context.sol", "file": "@openzeppelin/contracts/GSN/Context.sol", "scope": 2148, - "symbolAliases": [ - null - ], + "symbolAliases": [null], "unitAlias": "" }, "id": 1437, @@ -10115,18 +10031,11 @@ { "attributes": { "abstract": false, - "contractDependencies": [ - 3086, - 3618 - ], + "contractDependencies": [3086, 3618], "contractKind": "contract", "documentation": null, "fullyImplemented": true, - "linearizedBaseContracts": [ - 2147, - 3618, - 3086 - ], + "linearizedBaseContracts": [2147, 3618, 3086], "name": "WrappedAsset", "scope": 2148 }, @@ -10297,9 +10206,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "initialize", "overrides": null, "scope": 2147, @@ -10401,9 +10308,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 1457, @@ -10422,9 +10327,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -10442,10 +10345,7 @@ "typeString": "literal_string \"already initialized\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -10469,9 +10369,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1447, "type": "bool", "value": "initialized" @@ -10528,9 +10426,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1443, "type": "uint8", "value": "assetChain" @@ -10542,9 +10438,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1451, "type": "uint8", "value": "_assetChain" @@ -10579,9 +10473,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1445, "type": "bytes32", "value": "assetAddress" @@ -10593,9 +10485,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1453, "type": "bytes32", "value": "_assetAddress" @@ -10630,9 +10520,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1449, "type": "address", "value": "bridge" @@ -10656,9 +10544,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -15, "type": "msg", "value": "msg" @@ -10698,9 +10584,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1447, "type": "bool", "value": "initialized" @@ -10752,9 +10636,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1552, "type": "string storage ref", "value": "_symbol" @@ -10806,9 +10688,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1555, "type": "uint8", "value": "_decimals" @@ -10820,9 +10700,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1455, "type": "uint8", "value": "decimals" @@ -10858,9 +10736,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "mint", "overrides": null, "scope": 2147, @@ -10935,9 +10811,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 1496, @@ -10956,9 +10830,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -10976,10 +10848,7 @@ "typeString": "literal_string \"mint can only be called by the bridge\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -11018,9 +10887,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -15, "type": "msg", "value": "msg" @@ -11037,9 +10904,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1449, "type": "address", "value": "bridge" @@ -11090,9 +10955,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -11110,9 +10973,7 @@ "typeString": "uint256" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2043, "type": "function (address,uint256)", "value": "_mint" @@ -11124,9 +10985,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1492, "type": "address", "value": "account" @@ -11138,9 +10997,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1494, "type": "uint256", "value": "amount" @@ -11176,9 +11033,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "burn", "overrides": null, "scope": 2147, @@ -11253,9 +11108,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 1517, @@ -11274,9 +11127,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -11294,10 +11145,7 @@ "typeString": "literal_string \"burn can only be called by the bridge\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -11336,9 +11184,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -15, "type": "msg", "value": "msg" @@ -11355,9 +11201,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1449, "type": "address", "value": "bridge" @@ -11408,9 +11252,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -11428,9 +11270,7 @@ "typeString": "uint256" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2090, "type": "function (address,uint256)", "value": "_burn" @@ -11442,9 +11282,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1513, "type": "address", "value": "account" @@ -11456,9 +11294,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1515, "type": "uint256", "value": "amount" @@ -11761,9 +11597,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "name", "overrides": null, "scope": 2147, @@ -11782,9 +11616,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 1557, @@ -11841,9 +11673,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "string memory", "type_conversion": true @@ -11886,9 +11716,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes memory", "type_conversion": false @@ -11926,9 +11754,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": -1, "type": "abi", "value": "abi" @@ -11967,9 +11793,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "string memory", "type_conversion": false @@ -11983,9 +11807,7 @@ "typeString": "uint8" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1654, "type": "function (uint256) pure returns (string memory)", "value": "uintToString" @@ -11997,9 +11819,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1443, "type": "uint8", "value": "assetChain" @@ -12033,17 +11853,13 @@ { "attributes": { "argumentTypes": null, - "arguments": [ - null - ], + "arguments": [null], "isConstant": false, "isLValue": false, "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "string memory", "type_conversion": false @@ -12051,12 +11867,8 @@ "children": [ { "attributes": { - "argumentTypes": [ - null - ], - "overloadedDeclarations": [ - null - ], + "argumentTypes": [null], + "overloadedDeclarations": [null], "referencedDeclaration": 1740, "type": "function () view returns (string memory)", "value": "assetAddressString" @@ -12101,9 +11913,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "uintToString", "overrides": null, "scope": 2147, @@ -12207,9 +12017,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1578, "type": "uint256", "value": "_i" @@ -12281,9 +12089,7 @@ }, { "attributes": { - "assignments": [ - 1591 - ] + "assignments": [1591] }, "children": [ { @@ -12317,9 +12123,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1578, "type": "uint256", "value": "_i" @@ -12335,9 +12139,7 @@ }, { "attributes": { - "assignments": [ - 1595 - ], + "assignments": [1595], "initialValue": null }, "children": [ @@ -12394,9 +12196,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1591, "type": "uint256", "value": "j" @@ -12446,9 +12246,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1595, "type": "uint256", "value": "len" @@ -12483,9 +12281,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1591, "type": "uint256", "value": "j" @@ -12533,9 +12329,7 @@ }, { "attributes": { - "assignments": [ - 1610 - ] + "assignments": [1610] }, "children": [ { @@ -12574,9 +12368,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes memory", "type_conversion": false @@ -12614,9 +12406,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1595, "type": "uint256", "value": "len" @@ -12637,9 +12427,7 @@ }, { "attributes": { - "assignments": [ - 1617 - ] + "assignments": [1617] }, "children": [ { @@ -12688,9 +12476,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1595, "type": "uint256", "value": "len" @@ -12746,9 +12532,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1578, "type": "uint256", "value": "_i" @@ -12807,9 +12591,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1610, "type": "bytes memory", "value": "bstr" @@ -12833,9 +12615,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1617, "type": "uint256", "value": "k" @@ -12862,9 +12642,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes1", "type_conversion": true @@ -12907,9 +12685,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint8", "type_conversion": true @@ -13068,9 +12844,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1578, "type": "uint256", "value": "_i" @@ -13129,9 +12903,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "string memory", "type_conversion": true @@ -13169,9 +12941,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1610, "type": "bytes memory", "value": "bstr" @@ -13206,9 +12976,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "assetAddressString", "overrides": null, "scope": 2147, @@ -13219,9 +12987,7 @@ "children": [ { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 1655, @@ -13267,9 +13033,7 @@ "children": [ { "attributes": { - "assignments": [ - 1660 - ] + "assignments": [1660] }, "children": [ { @@ -13324,9 +13088,7 @@ }, { "attributes": { - "assignments": [ - 1664 - ] + "assignments": [1664] }, "children": [ { @@ -13360,9 +13122,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1445, "type": "bytes32", "value": "assetAddress" @@ -13378,9 +13138,7 @@ }, { "attributes": { - "assignments": [ - 1668 - ] + "assignments": [1668] }, "children": [ { @@ -13419,9 +13177,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "bytes memory", "type_conversion": false @@ -13518,9 +13274,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1664, "type": "bytes32", "value": "data" @@ -13575,9 +13329,7 @@ "children": [ { "attributes": { - "assignments": [ - 1680 - ] + "assignments": [1680] }, "children": [ { @@ -13648,9 +13400,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1680, "type": "uint256", "value": "i" @@ -13674,9 +13424,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1664, "type": "bytes32", "value": "data" @@ -13712,9 +13460,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1680, "type": "uint256", "value": "i" @@ -13761,9 +13507,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1668, "type": "bytes memory", "value": "str" @@ -13790,9 +13534,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1680, "type": "uint256", "value": "i" @@ -13841,9 +13583,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1660, "type": "bytes memory", "value": "alphabet" @@ -13860,9 +13600,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": true @@ -13905,9 +13643,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint8", "type_conversion": true @@ -14073,9 +13809,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1668, "type": "bytes memory", "value": "str" @@ -14190,9 +13924,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1660, "type": "bytes memory", "value": "alphabet" @@ -14209,9 +13941,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": true @@ -14254,9 +13984,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint8", "type_conversion": true @@ -14419,9 +14147,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "string memory", "type_conversion": true @@ -14459,9 +14185,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1668, "type": "bytes memory", "value": "str" @@ -14496,9 +14220,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "symbol", "overrides": null, "scope": 2147, @@ -14517,9 +14239,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 1742, @@ -14571,9 +14291,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1552, "type": "string storage ref", "value": "_symbol" @@ -14603,9 +14321,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "decimals", "overrides": null, "scope": 2147, @@ -14624,9 +14340,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 1751, @@ -14678,9 +14392,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1555, "type": "uint8", "value": "_decimals" @@ -14706,16 +14418,12 @@ }, { "attributes": { - "baseFunctions": [ - 3017 - ], + "baseFunctions": [3017], "functionSelector": "18160ddd", "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "totalSupply", "scope": 2147, "stateMutability": "view", @@ -14733,9 +14441,7 @@ }, { "attributes": { - "overrides": [ - null - ] + "overrides": [null] }, "id": 1761, "name": "OverrideSpecifier", @@ -14743,9 +14449,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 1760, @@ -14797,9 +14501,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1550, "type": "uint256", "value": "_totalSupply" @@ -14825,16 +14527,12 @@ }, { "attributes": { - "baseFunctions": [ - 3025 - ], + "baseFunctions": [3025], "functionSelector": "70a08231", "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "balanceOf", "scope": 2147, "stateMutability": "view", @@ -14852,9 +14550,7 @@ }, { "attributes": { - "overrides": [ - null - ] + "overrides": [null] }, "id": 1773, "name": "OverrideSpecifier", @@ -14951,9 +14647,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1542, "type": "mapping(address => uint256)", "value": "_balances" @@ -14965,9 +14659,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1771, "type": "address", "value": "account" @@ -14998,16 +14690,12 @@ }, { "attributes": { - "baseFunctions": [ - 3035 - ], + "baseFunctions": [3035], "functionSelector": "a9059cbb", "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "transfer", "scope": 2147, "stateMutability": "nonpayable", @@ -15025,9 +14713,7 @@ }, { "attributes": { - "overrides": [ - null - ] + "overrides": [null] }, "id": 1789, "name": "OverrideSpecifier", @@ -15144,9 +14830,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -15168,9 +14852,7 @@ "typeString": "uint256" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1997, "type": "function (address,address,uint256)", "value": "_transfer" @@ -15182,17 +14864,13 @@ { "attributes": { "argumentTypes": null, - "arguments": [ - null - ], + "arguments": [null], "isConstant": false, "isLValue": false, "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": false @@ -15200,12 +14878,8 @@ "children": [ { "attributes": { - "argumentTypes": [ - null - ], - "overloadedDeclarations": [ - null - ], + "argumentTypes": [null], + "overloadedDeclarations": [null], "referencedDeclaration": 3606, "type": "function () view returns (address payable)", "value": "_msgSender" @@ -15222,9 +14896,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1785, "type": "address", "value": "recipient" @@ -15236,9 +14908,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1787, "type": "uint256", "value": "amount" @@ -15296,16 +14966,12 @@ }, { "attributes": { - "baseFunctions": [ - 3045 - ], + "baseFunctions": [3045], "functionSelector": "dd62ed3e", "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "allowance", "scope": 2147, "stateMutability": "view", @@ -15323,9 +14989,7 @@ }, { "attributes": { - "overrides": [ - null - ] + "overrides": [null] }, "id": 1810, "name": "OverrideSpecifier", @@ -15461,9 +15125,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1548, "type": "mapping(address => mapping(address => uint256))", "value": "_allowances" @@ -15475,9 +15137,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1806, "type": "address", "value": "owner" @@ -15494,9 +15154,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1808, "type": "address", "value": "spender" @@ -15527,16 +15185,12 @@ }, { "attributes": { - "baseFunctions": [ - 3055 - ], + "baseFunctions": [3055], "functionSelector": "095ea7b3", "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "approve", "scope": 2147, "stateMutability": "nonpayable", @@ -15554,9 +15208,7 @@ }, { "attributes": { - "overrides": [ - null - ] + "overrides": [null] }, "id": 1828, "name": "OverrideSpecifier", @@ -15673,9 +15325,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -15697,9 +15347,7 @@ "typeString": "uint256" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2135, "type": "function (address,address,uint256)", "value": "_approve" @@ -15711,17 +15359,13 @@ { "attributes": { "argumentTypes": null, - "arguments": [ - null - ], + "arguments": [null], "isConstant": false, "isLValue": false, "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": false @@ -15729,12 +15373,8 @@ "children": [ { "attributes": { - "argumentTypes": [ - null - ], - "overloadedDeclarations": [ - null - ], + "argumentTypes": [null], + "overloadedDeclarations": [null], "referencedDeclaration": 3606, "type": "function () view returns (address payable)", "value": "_msgSender" @@ -15751,9 +15391,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1824, "type": "address", "value": "spender" @@ -15765,9 +15403,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1826, "type": "uint256", "value": "amount" @@ -15825,16 +15461,12 @@ }, { "attributes": { - "baseFunctions": [ - 3067 - ], + "baseFunctions": [3067], "functionSelector": "23b872dd", "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "transferFrom", "scope": 2147, "stateMutability": "nonpayable", @@ -15852,9 +15484,7 @@ }, { "attributes": { - "overrides": [ - null - ] + "overrides": [null] }, "id": 1851, "name": "OverrideSpecifier", @@ -16000,9 +15630,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -16024,9 +15652,7 @@ "typeString": "uint256" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1997, "type": "function (address,address,uint256)", "value": "_transfer" @@ -16038,9 +15664,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1845, "type": "address", "value": "sender" @@ -16052,9 +15676,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1847, "type": "address", "value": "recipient" @@ -16066,9 +15688,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1849, "type": "uint256", "value": "amount" @@ -16097,9 +15717,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -16121,9 +15739,7 @@ "typeString": "uint256" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2135, "type": "function (address,address,uint256)", "value": "_approve" @@ -16135,9 +15751,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1845, "type": "address", "value": "sender" @@ -16149,17 +15763,13 @@ { "attributes": { "argumentTypes": null, - "arguments": [ - null - ], + "arguments": [null], "isConstant": false, "isLValue": false, "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": false @@ -16167,12 +15777,8 @@ "children": [ { "attributes": { - "argumentTypes": [ - null - ], - "overloadedDeclarations": [ - null - ], + "argumentTypes": [null], + "overloadedDeclarations": [null], "referencedDeclaration": 3606, "type": "function () view returns (address payable)", "value": "_msgSender" @@ -16194,9 +15800,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -16246,9 +15850,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1548, "type": "mapping(address => mapping(address => uint256))", "value": "_allowances" @@ -16260,9 +15862,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1845, "type": "address", "value": "sender" @@ -16279,17 +15879,13 @@ { "attributes": { "argumentTypes": null, - "arguments": [ - null - ], + "arguments": [null], "isConstant": false, "isLValue": false, "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": false @@ -16297,12 +15893,8 @@ "children": [ { "attributes": { - "argumentTypes": [ - null - ], - "overloadedDeclarations": [ - null - ], + "argumentTypes": [null], + "overloadedDeclarations": [null], "referencedDeclaration": 3606, "type": "function () view returns (address payable)", "value": "_msgSender" @@ -16329,9 +15921,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1849, "type": "uint256", "value": "amount" @@ -16415,9 +16005,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "increaseAllowance", "overrides": null, "scope": 2147, @@ -16545,9 +16133,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -16569,9 +16155,7 @@ "typeString": "uint256" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2135, "type": "function (address,address,uint256)", "value": "_approve" @@ -16583,17 +16167,13 @@ { "attributes": { "argumentTypes": null, - "arguments": [ - null - ], + "arguments": [null], "isConstant": false, "isLValue": false, "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": false @@ -16601,12 +16181,8 @@ "children": [ { "attributes": { - "argumentTypes": [ - null - ], - "overloadedDeclarations": [ - null - ], + "argumentTypes": [null], + "overloadedDeclarations": [null], "referencedDeclaration": 3606, "type": "function () view returns (address payable)", "value": "_msgSender" @@ -16623,9 +16199,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1883, "type": "address", "value": "spender" @@ -16642,9 +16216,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -16690,9 +16262,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1548, "type": "mapping(address => mapping(address => uint256))", "value": "_allowances" @@ -16704,17 +16274,13 @@ { "attributes": { "argumentTypes": null, - "arguments": [ - null - ], + "arguments": [null], "isConstant": false, "isLValue": false, "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": false @@ -16722,9 +16288,7 @@ "children": [ { "attributes": { - "argumentTypes": [ - null - ], + "argumentTypes": [null], "overloadedDeclarations": [ null ], @@ -16749,9 +16313,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1883, "type": "address", "value": "spender" @@ -16773,9 +16335,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1885, "type": "uint256", "value": "addedValue" @@ -16842,9 +16402,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "decreaseAllowance", "overrides": null, "scope": 2147, @@ -16972,9 +16530,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -16996,9 +16552,7 @@ "typeString": "uint256" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2135, "type": "function (address,address,uint256)", "value": "_approve" @@ -17010,17 +16564,13 @@ { "attributes": { "argumentTypes": null, - "arguments": [ - null - ], + "arguments": [null], "isConstant": false, "isLValue": false, "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": false @@ -17028,12 +16578,8 @@ "children": [ { "attributes": { - "argumentTypes": [ - null - ], - "overloadedDeclarations": [ - null - ], + "argumentTypes": [null], + "overloadedDeclarations": [null], "referencedDeclaration": 3606, "type": "function () view returns (address payable)", "value": "_msgSender" @@ -17050,9 +16596,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1911, "type": "address", "value": "spender" @@ -17069,9 +16613,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -17121,9 +16663,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1548, "type": "mapping(address => mapping(address => uint256))", "value": "_allowances" @@ -17135,17 +16675,13 @@ { "attributes": { "argumentTypes": null, - "arguments": [ - null - ], + "arguments": [null], "isConstant": false, "isLValue": false, "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": false @@ -17153,9 +16689,7 @@ "children": [ { "attributes": { - "argumentTypes": [ - null - ], + "argumentTypes": [null], "overloadedDeclarations": [ null ], @@ -17180,9 +16714,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1911, "type": "address", "value": "spender" @@ -17204,9 +16736,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1913, "type": "uint256", "value": "subtractedValue" @@ -17289,9 +16819,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "_transfer", "overrides": null, "scope": 2147, @@ -17403,9 +16931,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 1946, @@ -17424,9 +16950,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -17444,10 +16968,7 @@ "typeString": "literal_string \"ERC20: transfer from the zero address\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -17474,9 +16995,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1940, "type": "address", "value": "sender" @@ -17493,9 +17012,7 @@ "isPure": true, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": true @@ -17594,9 +17111,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -17614,10 +17129,7 @@ "typeString": "literal_string \"ERC20: transfer to the zero address\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -17644,9 +17156,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1942, "type": "address", "value": "recipient" @@ -17663,9 +17173,7 @@ "isPure": true, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": true @@ -17780,9 +17288,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1542, "type": "mapping(address => uint256)", "value": "_balances" @@ -17794,9 +17300,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1940, "type": "address", "value": "sender" @@ -17818,9 +17322,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -17860,9 +17362,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1542, "type": "mapping(address => uint256)", "value": "_balances" @@ -17874,9 +17374,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1940, "type": "address", "value": "sender" @@ -17898,9 +17396,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1944, "type": "uint256", "value": "amount" @@ -17967,9 +17463,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1542, "type": "mapping(address => uint256)", "value": "_balances" @@ -17981,9 +17475,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1942, "type": "address", "value": "recipient" @@ -18005,9 +17497,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -18043,9 +17533,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1542, "type": "mapping(address => uint256)", "value": "_balances" @@ -18057,9 +17545,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1942, "type": "address", "value": "recipient" @@ -18081,9 +17567,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1944, "type": "uint256", "value": "amount" @@ -18117,9 +17601,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -18141,9 +17623,7 @@ "typeString": "uint256" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3076, "type": "function (address,address,uint256)", "value": "Transfer" @@ -18155,9 +17635,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1940, "type": "address", "value": "sender" @@ -18169,9 +17647,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1942, "type": "address", "value": "recipient" @@ -18183,9 +17659,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1944, "type": "uint256", "value": "amount" @@ -18219,9 +17693,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "_mint", "overrides": null, "scope": 2147, @@ -18304,9 +17776,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 2004, @@ -18325,9 +17795,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -18345,10 +17813,7 @@ "typeString": "literal_string \"ERC20: mint to the zero address\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -18375,9 +17840,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2000, "type": "address", "value": "account" @@ -18394,9 +17857,7 @@ "isPure": true, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": true @@ -18501,9 +17962,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1550, "type": "uint256", "value": "_totalSupply" @@ -18520,9 +17979,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -18548,9 +18005,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1550, "type": "uint256", "value": "_totalSupply" @@ -18567,9 +18022,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2002, "type": "uint256", "value": "amount" @@ -18619,9 +18072,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1542, "type": "mapping(address => uint256)", "value": "_balances" @@ -18633,9 +18084,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2000, "type": "address", "value": "account" @@ -18657,9 +18106,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -18695,9 +18142,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1542, "type": "mapping(address => uint256)", "value": "_balances" @@ -18709,9 +18154,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2000, "type": "address", "value": "account" @@ -18733,9 +18176,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2002, "type": "uint256", "value": "amount" @@ -18769,9 +18210,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -18793,9 +18232,7 @@ "typeString": "uint256" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3076, "type": "function (address,address,uint256)", "value": "Transfer" @@ -18812,9 +18249,7 @@ "isPure": true, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": true @@ -18874,9 +18309,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2000, "type": "address", "value": "account" @@ -18888,9 +18321,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2002, "type": "uint256", "value": "amount" @@ -18924,9 +18355,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "_burn", "overrides": null, "scope": 2147, @@ -19009,9 +18438,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 2050, @@ -19030,9 +18457,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -19050,10 +18475,7 @@ "typeString": "literal_string \"ERC20: burn from the zero address\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -19080,9 +18502,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2046, "type": "address", "value": "account" @@ -19099,9 +18519,7 @@ "isPure": true, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": true @@ -19216,9 +18634,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1542, "type": "mapping(address => uint256)", "value": "_balances" @@ -19230,9 +18646,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2046, "type": "address", "value": "account" @@ -19254,9 +18668,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -19296,9 +18708,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1542, "type": "mapping(address => uint256)", "value": "_balances" @@ -19310,9 +18720,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2046, "type": "address", "value": "account" @@ -19334,9 +18742,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2048, "type": "uint256", "value": "amount" @@ -19393,9 +18799,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1550, "type": "uint256", "value": "_totalSupply" @@ -19412,9 +18816,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "uint256", "type_conversion": false @@ -19440,9 +18842,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1550, "type": "uint256", "value": "_totalSupply" @@ -19459,9 +18859,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2048, "type": "uint256", "value": "amount" @@ -19495,9 +18893,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -19519,9 +18915,7 @@ "typeString": "uint256" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3076, "type": "function (address,address,uint256)", "value": "Transfer" @@ -19533,9 +18927,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2046, "type": "address", "value": "account" @@ -19552,9 +18944,7 @@ "isPure": true, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": true @@ -19614,9 +19004,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2048, "type": "uint256", "value": "amount" @@ -19650,9 +19038,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "_approve", "overrides": null, "scope": 2147, @@ -19764,9 +19150,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 2099, @@ -19785,9 +19169,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -19805,10 +19187,7 @@ "typeString": "literal_string \"ERC20: approve from the zero address\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -19835,9 +19214,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2093, "type": "address", "value": "owner" @@ -19854,9 +19231,7 @@ "isPure": true, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": true @@ -19955,9 +19330,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -19975,10 +19348,7 @@ "typeString": "literal_string \"ERC20: approve to the zero address\"" } ], - "overloadedDeclarations": [ - -18, - -18 - ], + "overloadedDeclarations": [-18, -18], "referencedDeclaration": -18, "type": "function (bool,string memory) pure", "value": "require" @@ -20005,9 +19375,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2095, "type": "address", "value": "spender" @@ -20024,9 +19392,7 @@ "isPure": true, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "address payable", "type_conversion": true @@ -20151,9 +19517,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1548, "type": "mapping(address => mapping(address => uint256))", "value": "_allowances" @@ -20165,9 +19529,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2093, "type": "address", "value": "owner" @@ -20184,9 +19546,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2095, "type": "address", "value": "spender" @@ -20203,9 +19563,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2097, "type": "uint256", "value": "amount" @@ -20234,9 +19592,7 @@ "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], + "names": [null], "tryCall": false, "type": "tuple()", "type_conversion": false @@ -20258,9 +19614,7 @@ "typeString": "uint256" } ], - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 3085, "type": "function (address,address,uint256)", "value": "Approval" @@ -20272,9 +19626,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2093, "type": "address", "value": "owner" @@ -20286,9 +19638,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2095, "type": "address", "value": "spender" @@ -20300,9 +19650,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2097, "type": "uint256", "value": "amount" @@ -20336,9 +19684,7 @@ "implemented": true, "isConstructor": false, "kind": "function", - "modifiers": [ - null - ], + "modifiers": [null], "name": "_setupDecimals", "overrides": null, "scope": 2147, @@ -20392,9 +19738,7 @@ }, { "attributes": { - "parameters": [ - null - ] + "parameters": [null] }, "children": [], "id": 2140, @@ -20419,9 +19763,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 1555, "type": "uint8", "value": "_decimals" @@ -20433,9 +19775,7 @@ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], + "overloadedDeclarations": [null], "referencedDeclaration": 2138, "type": "uint8", "value": "decimals_" @@ -20525,4 +19865,4 @@ "methods": {}, "version": 1 } -} \ No newline at end of file +} diff --git a/packages/bridge-sdk/package.json b/packages/bridge-sdk/package.json index 41c7751..8edf4fb 100644 --- a/packages/bridge-sdk/package.json +++ b/packages/bridge-sdk/package.json @@ -1,15 +1,31 @@ { "name": "@solana/bridge-sdk", "version": "0.0.1", + "description": "Bridge common sdk utilities", + "main": "dist/lib/index.js", + "types": "dist/lib/index.d.ts", + "exports": { + ".": "./dist/lib/" + }, + "license": "Apache-2.0", + "publishConfig": { + "access": "public" + }, + "engines": { + "node": ">=10" + }, "dependencies": { - "@solana/wallet-base": "0.0.1", + "@babel/preset-typescript": "^7.13.0", "@oyster/common": "0.0.1", "@solana/spl-token": "0.0.13", "@solana/spl-token-swap": "0.1.0", - "@solana/web3.js": "^0.86.2", + "@solana/wallet-base": "0.0.1", + "@solana/wallet-ledger": "0.0.1", + "@solana/web3.js": "^1.5.0", + "bignumber.js": "^9.0.1", "bn.js": "^5.1.3", "bs58": "^4.0.1", - "buffer-layout": "^1.2.0", + "buffer-layout": "1.2.0", "ethers": "^4.0.48", "eventemitter3": "^4.0.7", "lodash": "^4.17.20", @@ -17,9 +33,20 @@ "web3": "^1.3.0" }, "scripts": { + "build": "tsc", + "start": "npm-run-all --parallel watch watch-css watch-css-src", + "watch-css": "less-watch-compiler src/ dist/lib/", + "watch-css-src": "less-watch-compiler src/ src/", + "watch": "tsc --watch", + "test": "jest test", + "clean": "rm -rf dist", + "prepare": "run-s clean build", "format:fix": "prettier --write \"**/*.+(js|jsx|ts|tsx|json|css|md)\"", "ethers": "typechain --target ethers-v4 --outDir src/contracts 'contracts/*.json'" }, + "files": [ + "dist" + ], "browserslist": { "production": [ ">0.2%", @@ -36,6 +63,14 @@ "type": "git", "url": "https://github.com/solana-labs/oyster" }, + "peerDependencies": { + "react": "*", + "react-dom": "*" + }, + "resolutions": { + "react": "16.13.1", + "react-dom": "16.13.1" + }, "homepage": ".", "devDependencies": { "@typechain/ethers-v4": "^1.0.0", diff --git a/packages/bridge-sdk/src/bridge/claim.ts b/packages/bridge-sdk/src/bridge/claim.ts new file mode 100644 index 0000000..254afd4 --- /dev/null +++ b/packages/bridge-sdk/src/bridge/claim.ts @@ -0,0 +1,21 @@ +// 40 - ExecutedVAA (claim) +import { publicKey } from '@oyster/common/dist/lib/utils/layout'; +import * as BufferLayout from 'buffer-layout'; + +export const ClaimedVAA = BufferLayout.struct([ + BufferLayout.blob(32, 'hash'), + BufferLayout.u32('vaaTime'), + BufferLayout.u8('initialized'), + //BufferLayout.seq(BufferLayout.u8(), 3), +]); + +/* +pub struct ClaimedVAA { + /// hash of the vaa + pub hash: [u8; 32], + /// time the vaa was submitted + pub vaa_time: u32, + /// Is `true` if this structure has been initialized. + pub is_initialized: bool, +} +*/ diff --git a/packages/bridge/src/models/bridge/config.ts b/packages/bridge-sdk/src/bridge/config.ts similarity index 55% rename from packages/bridge/src/models/bridge/config.ts rename to packages/bridge-sdk/src/bridge/config.ts index b236669..0d79716 100644 --- a/packages/bridge/src/models/bridge/config.ts +++ b/packages/bridge-sdk/src/bridge/config.ts @@ -1,10 +1,10 @@ // 44 - bridge config -import { Layout } from '@oyster/common'; +import { publicKey } from '@oyster/common/dist/lib/utils/layout'; import * as BufferLayout from 'buffer-layout'; -export const BridgeLayout: typeof BufferLayout.Structure = BufferLayout.struct([ +export const BridgeLayout = BufferLayout.struct([ BufferLayout.u32('guardianSetIndex'), BufferLayout.u8('guardianSetExpirationTime'), - Layout.publicKey('tokenProgram'), + publicKey('tokenProgram'), BufferLayout.u8('isInitialized'), ]); diff --git a/packages/bridge/src/models/bridge/constants.ts b/packages/bridge-sdk/src/bridge/constants.ts similarity index 100% rename from packages/bridge/src/models/bridge/constants.ts rename to packages/bridge-sdk/src/bridge/constants.ts diff --git a/packages/bridge/src/models/bridge/custody.ts b/packages/bridge-sdk/src/bridge/custody.ts similarity index 100% rename from packages/bridge/src/models/bridge/custody.ts rename to packages/bridge-sdk/src/bridge/custody.ts diff --git a/packages/bridge/src/models/bridge/guardianSet.ts b/packages/bridge-sdk/src/bridge/guardianSet.ts similarity index 100% rename from packages/bridge/src/models/bridge/guardianSet.ts rename to packages/bridge-sdk/src/bridge/guardianSet.ts diff --git a/packages/bridge/src/models/bridge/helpers.ts b/packages/bridge-sdk/src/bridge/helpers.ts similarity index 100% rename from packages/bridge/src/models/bridge/helpers.ts rename to packages/bridge-sdk/src/bridge/helpers.ts diff --git a/packages/bridge/src/models/bridge/index.ts b/packages/bridge-sdk/src/bridge/index.ts similarity index 100% rename from packages/bridge/src/models/bridge/index.ts rename to packages/bridge-sdk/src/bridge/index.ts diff --git a/packages/bridge/src/models/bridge/lock.ts b/packages/bridge-sdk/src/bridge/lock.ts similarity index 100% rename from packages/bridge/src/models/bridge/lock.ts rename to packages/bridge-sdk/src/bridge/lock.ts diff --git a/packages/bridge/src/models/bridge/meta.ts b/packages/bridge-sdk/src/bridge/meta.ts similarity index 100% rename from packages/bridge/src/models/bridge/meta.ts rename to packages/bridge-sdk/src/bridge/meta.ts diff --git a/packages/bridge/src/models/bridge/signatureState.ts b/packages/bridge-sdk/src/bridge/signatureState.ts similarity index 100% rename from packages/bridge/src/models/bridge/signatureState.ts rename to packages/bridge-sdk/src/bridge/signatureState.ts diff --git a/packages/bridge/src/models/bridge/transfer/fromSolana.ts b/packages/bridge-sdk/src/bridge/transfer/fromSolana.ts similarity index 59% rename from packages/bridge/src/models/bridge/transfer/fromSolana.ts rename to packages/bridge-sdk/src/bridge/transfer/fromSolana.ts index d6b8dd2..4c23179 100644 --- a/packages/bridge/src/models/bridge/transfer/fromSolana.ts +++ b/packages/bridge-sdk/src/bridge/transfer/fromSolana.ts @@ -1,7 +1,7 @@ -import { programIds, sendTransaction } from '@oyster/common'; +import { programIds, sendTransactionWithRetry, sleep } from '@oyster/common'; import { WalletAdapter } from '@solana/wallet-base'; import { ethers } from 'ethers'; -import { WormholeFactory } from '../../../contracts/WormholeFactory'; +import { WormholeFactory } from '../../contracts/WormholeFactory'; import { bridgeAuthorityKey } from './../helpers'; import { Connection, PublicKey, SystemProgram } from '@solana/web3.js'; import { Token } from '@solana/spl-token'; @@ -9,6 +9,7 @@ import { ProgressUpdate, TransferRequest } from './interface'; import BN from 'bn.js'; import { createLockAssetInstruction } from '../lock'; import { TransferOutProposalLayout } from '../transferOutProposal'; +import { SolanaBridge } from '../../core'; export const fromSolana = async ( connection: Connection, @@ -16,17 +17,17 @@ export const fromSolana = async ( request: TransferRequest, provider: ethers.providers.Web3Provider, setProgress: (update: ProgressUpdate) => void, + bridge?: SolanaBridge, ) => { if ( !request.asset || !request.amount || - !request.recipient || !request.to || - !request.info + !request.info || + !bridge ) { return; } - const walletName = 'MetaMask'; const signer = provider?.getSigner(); request.recipient = Buffer.from((await signer.getAddress()).slice(2), 'hex'); const nonce = await provider.getTransactionCount( @@ -34,11 +35,6 @@ export const fromSolana = async ( 'pending', ); - const amountBN = ethers.utils.parseUnits( - request.amount.toString(), - request.info.decimals, - ); - let counter = 0; // check difference between lock/approve (invoke lock if allowance < amount) const steps = { @@ -66,7 +62,7 @@ export const fromSolana = async ( return; } - let group = 'Lock assets'; + let group = 'Initiate transfer'; const programs = programIds(); const bridgeId = programs.wormhole.pubkey; const authorityKey = await bridgeAuthorityKey(bridgeId); @@ -79,7 +75,7 @@ export const fromSolana = async ( wallet.publicKey, new PublicKey(request.info.address), new PublicKey(request.info.mint), - new BN(request.amount.toString()), + new BN(amount), request.to, request.recipient, { @@ -100,18 +96,34 @@ export const fromSolana = async ( amount, ); + setProgress({ + message: 'Waiting for Solana approval...', + type: 'user', + group, + step: counter++, + }); let fee_ix = SystemProgram.transfer({ fromPubkey: wallet.publicKey, toPubkey: authorityKey, lamports: await getTransferFee(connection), }); - const { slot } = await sendTransaction( + const { slot } = await sendTransactionWithRetry( connection, wallet, [ix, fee_ix, lock_ix], [], - true, + undefined, + false, + undefined, + () => { + setProgress({ + message: 'Executing Solana Transaction', + type: 'wait', + group, + step: counter++, + }); + }, ); return steps.wait(request, transferKey, slot); @@ -123,32 +135,39 @@ export const fromSolana = async ( ) => { return new Promise((resolve, reject) => { let completed = false; + let unsubscribed = false; let startSlot = slot; let group = 'Lock assets'; - + const solConfirmationMessage = (current: number) => + `Awaiting Solana confirmations: ${current} out of 32`; + let replaceMessage = false; let slotUpdateListener = connection.onSlotChange(slot => { - if (completed) return; - const passedSlots = slot.slot - startSlot; + if (unsubscribed) { + return; + } + + const passedSlots = Math.min(Math.max(slot.slot - startSlot, 0), 32); const isLast = passedSlots - 1 === 31; - if (passedSlots < 32) { - // setLoading({ - // loading: true, - // message: "Awaiting confirmations", - // progress: { - // completion: (slot.slot - startSlot) / 32 * 100, - // content: `${slot.slot - startSlot}/${32}` - // } - // }) - // setProgress({ - // message: ethConfirmationMessage(passedBlocks), - // type: isLast ? 'done' : 'wait', - // step: counter++, - // group, - // replace: passedBlocks > 0, - // }); - } else { - //setLoading({loading: true, message: "Awaiting guardian confirmation"}) + if (passedSlots <= 32) { + setProgress({ + message: solConfirmationMessage(passedSlots), + type: isLast ? 'done' : 'wait', + step: counter++, + group, + replace: replaceMessage, + }); + replaceMessage = true; + } + + if (completed || isLast) { + unsubscribed = true; + setProgress({ + message: 'Awaiting guardian confirmation. (Up to few min.)', + type: 'wait', + step: counter++, + group, + }); } }); @@ -175,28 +194,37 @@ export const fromSolana = async ( completed = true; connection.removeAccountChangeListener(accountChangeListener); connection.removeSlotChangeListener(slotUpdateListener); + let signatures; - // let signatures = await bridge.fetchSignatureStatus( - // lockup.signatureAccount, - // ); - // let sigData = Buffer.of( - // ...signatures.reduce((previousValue, currentValue) => { - // previousValue.push(currentValue.index); - // previousValue.push(...currentValue.signature); + while (!signatures) { + try { + signatures = await bridge.fetchSignatureStatus( + lockup.signatureAccount, + ); + break; + } catch { + await sleep(500); + } + } - // return previousValue; - // }, new Array()), - // ); + let sigData = Buffer.of( + ...signatures.reduce((previousValue, currentValue) => { + previousValue.push(currentValue.index); + previousValue.push(...currentValue.signature); + + return previousValue; + }, new Array()), + ); + + vaa = Buffer.concat([ + vaa.slice(0, 5), + Buffer.of(signatures.length), + sigData, + vaa.slice(6), + ]); - // vaa = Buffer.concat([ - // vaa.slice(0, 5), - // Buffer.of(signatures.length), - // sigData, - // vaa.slice(6), - // ]); - // transferVAA = vaa try { - await steps.postVAA(request); + await steps.postVAA(request, vaa); resolve(); } catch { reject(); @@ -206,22 +234,30 @@ export const fromSolana = async ( ); }); }, - postVAA: async (request: TransferRequest) => { + postVAA: async (request: TransferRequest, vaa: any) => { let wh = WormholeFactory.connect(programIds().wormhole.bridge, signer); - - // setLoading({ - // ...loading, - // loading: true, - // message: "Sign the claim...", - // }) - // let tx = await wh.submitVAA(vaa); - // setLoading({ - // ...loading, - // loading: true, - // message: "Waiting for tokens unlock to be mined...", - // }) - // await tx.wait(1); - // message.success({content: "Execution of VAA succeeded", key: "eth_tx"}) + let group = 'Finalizing transfer'; + setProgress({ + message: 'Sign the claim...', + type: 'wait', + group, + step: counter++, + }); + let tx = await wh.submitVAA(vaa); + setProgress({ + message: 'Waiting for tokens unlock to be mined... (Up to few min.)', + type: 'wait', + group, + step: counter++, + }); + await tx.wait(1); + setProgress({ + message: 'Execution of VAA succeeded', + type: 'done', + group, + step: counter++, + }); + //message.success({content: "", key: "eth_tx"}) }, }; diff --git a/packages/bridge/src/models/bridge/transfer/index.ts b/packages/bridge-sdk/src/bridge/transfer/index.ts similarity index 100% rename from packages/bridge/src/models/bridge/transfer/index.ts rename to packages/bridge-sdk/src/bridge/transfer/index.ts diff --git a/packages/bridge/src/models/bridge/transfer/interface.ts b/packages/bridge-sdk/src/bridge/transfer/interface.ts similarity index 70% rename from packages/bridge/src/models/bridge/transfer/interface.ts rename to packages/bridge-sdk/src/bridge/transfer/interface.ts index 6c877d6..3eb4b85 100644 --- a/packages/bridge/src/models/bridge/transfer/interface.ts +++ b/packages/bridge-sdk/src/bridge/transfer/interface.ts @@ -1,6 +1,5 @@ -import BN from 'bn.js'; +import { BigNumber } from 'bignumber.js'; import { ethers } from 'ethers'; -import { BigNumber } from 'ethers/utils'; import { ASSET_CHAIN } from '../constants'; export interface ProgressUpdate { @@ -16,7 +15,7 @@ export interface TransferRequestInfo { name: string; balance: BigNumber; decimals: number; - allowance: BigNumber; + allowance: ethers.utils.BigNumber; isWrapped: boolean; chainID: number; assetAddress: Buffer; @@ -37,12 +36,10 @@ export interface TransferRequest { export const displayBalance = (info?: TransferRequestInfo) => { try { - return ( - new BN(info?.balance?.toString() || 0) - .div(new BN(10).pow(new BN(Math.min((info?.decimals || 0) - 2, 0)))) - .toNumber() / 100 - ); - } catch { + const balance = info?.balance || new BigNumber(0); + const precision = new BigNumber(10).pow(info?.decimals || new BigNumber(0)); + return balance.div(precision).toNumber(); + } catch (e) { return 0; } }; diff --git a/packages/bridge/src/models/bridge/transfer/toSolana.ts b/packages/bridge-sdk/src/bridge/transfer/toSolana.ts similarity index 95% rename from packages/bridge/src/models/bridge/transfer/toSolana.ts rename to packages/bridge-sdk/src/bridge/transfer/toSolana.ts index 96c0863..57be58a 100644 --- a/packages/bridge/src/models/bridge/transfer/toSolana.ts +++ b/packages/bridge-sdk/src/bridge/transfer/toSolana.ts @@ -1,15 +1,15 @@ import { programIds, getMultipleAccounts, - sendTransaction, + sendTransactionWithRetry, cache, TokenAccountParser, ParsedAccount, createAssociatedTokenAccountInstruction, } from '@oyster/common'; import { ethers } from 'ethers'; -import { ERC20Factory } from '../../../contracts/ERC20Factory'; -import { WormholeFactory } from '../../../contracts/WormholeFactory'; +import { ERC20Factory } from '../../contracts/ERC20Factory'; +import { WormholeFactory } from '../../contracts/WormholeFactory'; import { AssetMeta, createWrappedAssetInstruction } from './../meta'; import { bridgeAuthorityKey, wrappedAssetMintKey } from './../helpers'; import { @@ -21,6 +21,7 @@ import { import { AccountInfo } from '@solana/spl-token'; import { TransferRequest, ProgressUpdate } from './interface'; import { WalletAdapter } from '@solana/wallet-base'; +import { BigNumber } from 'bignumber.js'; export const toSolana = async ( connection: Connection, @@ -39,6 +40,9 @@ export const toSolana = async ( signer.getAddress(), 'pending', ); + const amountBigNumber = new BigNumber(request.amount.toString()).toFormat( + request.info.decimals, + ); const amountBN = ethers.utils.parseUnits( request.amount.toString(), @@ -139,12 +143,11 @@ export const toSolana = async ( step: counter++, }); - await sendTransaction( + await sendTransactionWithRetry( connection, wallet, instructions, signers, - true, ); } } catch (err) { @@ -177,7 +180,7 @@ export const toSolana = async ( }); let res = await e.approve(programIds().wormhole.bridge, amountBN); setProgress({ - message: 'Waiting for ETH transaction to be mined...', + message: 'Waiting for ETH transaction to be mined... (Up to few min.)', type: 'wait', group, step: counter++, @@ -240,7 +243,7 @@ export const toSolana = async ( false, ); setProgress({ - message: 'Waiting for ETH transaction to be mined...', + message: 'Waiting for ETH transaction to be mined... (Up to few min.)', type: 'wait', group, step: counter++, diff --git a/packages/bridge/src/models/bridge/transferOutProposal.ts b/packages/bridge-sdk/src/bridge/transferOutProposal.ts similarity index 100% rename from packages/bridge/src/models/bridge/transferOutProposal.ts rename to packages/bridge-sdk/src/bridge/transferOutProposal.ts diff --git a/packages/bridge/src/contracts/ERC20.d.ts b/packages/bridge-sdk/src/contracts/ERC20.d.ts similarity index 100% rename from packages/bridge/src/contracts/ERC20.d.ts rename to packages/bridge-sdk/src/contracts/ERC20.d.ts diff --git a/packages/bridge/src/contracts/ERC20Factory.ts b/packages/bridge-sdk/src/contracts/ERC20Factory.ts similarity index 100% rename from packages/bridge/src/contracts/ERC20Factory.ts rename to packages/bridge-sdk/src/contracts/ERC20Factory.ts diff --git a/packages/bridge/src/contracts/IERC20.d.ts b/packages/bridge-sdk/src/contracts/IERC20.d.ts similarity index 100% rename from packages/bridge/src/contracts/IERC20.d.ts rename to packages/bridge-sdk/src/contracts/IERC20.d.ts diff --git a/packages/bridge/src/contracts/IERC20Factory.ts b/packages/bridge-sdk/src/contracts/IERC20Factory.ts similarity index 100% rename from packages/bridge/src/contracts/IERC20Factory.ts rename to packages/bridge-sdk/src/contracts/IERC20Factory.ts diff --git a/packages/bridge/src/contracts/WETH.d.ts b/packages/bridge-sdk/src/contracts/WETH.d.ts similarity index 100% rename from packages/bridge/src/contracts/WETH.d.ts rename to packages/bridge-sdk/src/contracts/WETH.d.ts diff --git a/packages/bridge/src/contracts/WETHFactory.ts b/packages/bridge-sdk/src/contracts/WETHFactory.ts similarity index 100% rename from packages/bridge/src/contracts/WETHFactory.ts rename to packages/bridge-sdk/src/contracts/WETHFactory.ts diff --git a/packages/bridge/src/contracts/Wormhole.d.ts b/packages/bridge-sdk/src/contracts/Wormhole.d.ts similarity index 100% rename from packages/bridge/src/contracts/Wormhole.d.ts rename to packages/bridge-sdk/src/contracts/Wormhole.d.ts diff --git a/packages/bridge/src/contracts/WormholeFactory.ts b/packages/bridge-sdk/src/contracts/WormholeFactory.ts similarity index 100% rename from packages/bridge/src/contracts/WormholeFactory.ts rename to packages/bridge-sdk/src/contracts/WormholeFactory.ts diff --git a/packages/bridge/src/contracts/WrappedAsset.d.ts b/packages/bridge-sdk/src/contracts/WrappedAsset.d.ts similarity index 100% rename from packages/bridge/src/contracts/WrappedAsset.d.ts rename to packages/bridge-sdk/src/contracts/WrappedAsset.d.ts diff --git a/packages/bridge/src/contracts/WrappedAssetFactory.ts b/packages/bridge-sdk/src/contracts/WrappedAssetFactory.ts similarity index 100% rename from packages/bridge/src/contracts/WrappedAssetFactory.ts rename to packages/bridge-sdk/src/contracts/WrappedAssetFactory.ts diff --git a/packages/bridge/src/contracts/index.d.ts b/packages/bridge-sdk/src/contracts/index.d.ts similarity index 100% rename from packages/bridge/src/contracts/index.d.ts rename to packages/bridge-sdk/src/contracts/index.d.ts diff --git a/packages/bridge/src/core/bridge.ts b/packages/bridge-sdk/src/core/bridge.ts similarity index 87% rename from packages/bridge/src/core/bridge.ts rename to packages/bridge-sdk/src/core/bridge.ts index 6fd70b3..a6d943d 100644 --- a/packages/bridge/src/core/bridge.ts +++ b/packages/bridge-sdk/src/core/bridge.ts @@ -5,6 +5,17 @@ import assert from 'assert'; // @ts-ignore import * as BufferLayout from 'buffer-layout'; import * as bs58 from 'bs58'; +import { AssetMeta } from '../bridge'; + +export enum LockupStatus { + AWAITING_VAA, + UNCLAIMED_VAA, + COMPLETED, +} + +export interface LockupWithStatus extends Lockup { + status: LockupStatus; +} export interface Lockup { lockupAddress: PublicKey; @@ -71,7 +82,40 @@ class SolanaBridge { data, }); } + // fetchAssetMeta fetches the AssetMeta for an SPL token + async fetchAssetMeta(mint: PublicKey): Promise { + // @ts-ignore + let configKey = await this.getConfigKey(); + let seeds: Array = [ + Buffer.from('meta'), + configKey.toBuffer(), + mint.toBuffer(), + ]; + // @ts-ignore + let metaKey = ( + await solanaWeb3.PublicKey.findProgramAddress(seeds, this.programID) + )[0]; + let metaInfo = await this.connection.getAccountInfo(metaKey); + if (metaInfo == null || metaInfo.lamports == 0) { + return { + address: mint.toBuffer(), + chain: CHAIN_ID_SOLANA, + decimals: 0, + }; + } else { + const dataLayout = BufferLayout.struct([ + BufferLayout.u8('assetChain'), + BufferLayout.blob(32, 'assetAddress'), + ]); + let wrappedMeta = dataLayout.decode(metaInfo?.data); + return { + address: wrappedMeta.assetAddress, + chain: wrappedMeta.assetChain, + decimals: 0, + }; + } + } // fetchSignatureStatus fetches the signatures for a VAA async fetchSignatureStatus(signatureStatus: PublicKey): Promise { let signatureInfo = await this.connection.getAccountInfo( diff --git a/packages/bridge/src/core/index.ts b/packages/bridge-sdk/src/core/index.ts similarity index 100% rename from packages/bridge/src/core/index.ts rename to packages/bridge-sdk/src/core/index.ts diff --git a/packages/bridge/src/core/utils.ts b/packages/bridge-sdk/src/core/utils.ts similarity index 100% rename from packages/bridge/src/core/utils.ts rename to packages/bridge-sdk/src/core/utils.ts diff --git a/packages/bridge-sdk/src/index.ts b/packages/bridge-sdk/src/index.ts index 4dfd2bb..ea94e5d 100644 --- a/packages/bridge-sdk/src/index.ts +++ b/packages/bridge-sdk/src/index.ts @@ -1 +1,10 @@ -// TODO: move bridge interaction code to this library +export * as bridge from './bridge'; +export * from './bridge'; +export * as core from './core'; +export * from './core'; + +export * from './contracts/ERC20Factory'; +export * from './contracts/IERC20Factory'; +export * from './contracts/WETHFactory'; +export * from './contracts/WormholeFactory'; +export * from './contracts/WrappedAssetFactory'; diff --git a/packages/bridge-sdk/src/types/buffer-layout.d.ts b/packages/bridge-sdk/src/types/buffer-layout.d.ts new file mode 100644 index 0000000..e75a7e2 --- /dev/null +++ b/packages/bridge-sdk/src/types/buffer-layout.d.ts @@ -0,0 +1,4 @@ +declare module 'buffer-layout' { + const bl: any; + export = bl; +} diff --git a/packages/bridge-sdk/tsconfig.json b/packages/bridge-sdk/tsconfig.json index 7420e1f..da087cf 100644 --- a/packages/bridge-sdk/tsconfig.json +++ b/packages/bridge-sdk/tsconfig.json @@ -1,22 +1,23 @@ { "compilerOptions": { - "target": "es5", - "lib": ["dom", "dom.iterable", "esnext"], - "allowJs": true, + "module": "commonjs", + "target": "es2019", + "moduleResolution": "node", "skipLibCheck": true, "esModuleInterop": true, - "allowSyntheticDefaultImports": true, "strict": true, + "allowJs": true, + "allowSyntheticDefaultImports": true, "forceConsistentCasingInFileNames": true, - "noFallthroughCasesInSwitch": true, - "module": "esnext", - "moduleResolution": "node", "resolveJsonModule": true, - "isolatedModules": true, - "downlevelIteration": true, - "noEmit": true, "jsx": "react", - "typeRoots": ["types", "../../types", "../../node_modules/@types"] + "typeRoots": ["types", "../../types", "../../node_modules/@types"], + "outDir": "./dist/lib", + "rootDir": "./src", + "composite": true, + "declaration": true, + "declarationMap": true, + "sourceMap": true }, - "include": ["src"] + "include": ["src/**/*"] } diff --git a/packages/bridge/_colors.less b/packages/bridge/_colors.less index fe0cb72..ccef6e6 100644 --- a/packages/bridge/_colors.less +++ b/packages/bridge/_colors.less @@ -1,4 +1,5 @@ @surge-20: #00CC82; +@surge-30: #00B372; @tungsten-100: #06101a; @tungsten-80: #2F506F; @tungsten-60: #547595; diff --git a/packages/bridge/package.json b/packages/bridge/package.json index 52909f9..0e876ec 100644 --- a/packages/bridge/package.json +++ b/packages/bridge/package.json @@ -13,7 +13,9 @@ "@solana/spl-token-registry": "^0.2.0", "@solana/spl-token-swap": "0.1.0", "@solana/wallet-base": "0.0.1", - "@solana/web3.js": "^0.86.2", + "@solana/wallet-ledger": "0.0.1", + "@solana/bridge-sdk": "0.0.1", + "@solana/web3.js": "^1.5.0", "@testing-library/jest-dom": "^4.2.4", "@testing-library/react": "^9.5.0", "@testing-library/user-event": "^7.2.1", @@ -36,6 +38,7 @@ "@web3-react/walletlink-connector": "^6.0.9", "@welldone-software/why-did-you-render": "^6.0.5", "animejs": "^3.2.1", + "bignumber.js": "^9.0.1", "bn.js": "^5.1.3", "bs58": "^4.0.1", "buffer-layout": "^1.2.0", @@ -47,6 +50,7 @@ "eventemitter3": "^4.0.7", "fortmatic": "^2.2.1", "identicon.js": "^2.3.3", + "javascript-time-ago": "^2.3.4", "jazzicon": "^1.5.0", "lodash": "^4.17.20", "react": "16.13.1", @@ -97,13 +101,14 @@ "@types/bn.js": "^5.1.0", "@types/bs58": "^4.0.1", "@types/identicon.js": "^2.3.0", + "@types/javascript-time-ago": "^2.0.2", "@types/jest": "^24.9.1", "@types/node": "^12.12.62", "arweave-deploy": "^1.9.1", "gh-pages": "^3.1.0", "npm-link-shared": "0.5.6", - "typechain": "^4.0.3", - "prettier": "^2.1.2" + "prettier": "^2.1.2", + "typechain": "^4.0.3" }, "peerDependencies": { "react": "*", diff --git a/packages/bridge/public/help/overview.svg b/packages/bridge/public/help/overview.svg new file mode 100644 index 0000000..0685518 --- /dev/null +++ b/packages/bridge/public/help/overview.svg @@ -0,0 +1,16 @@ + + + + + + + EthereumSolanaTerraBridgeLockupobservationPostVAAby bridgeEnd userwalletVAA retrievalPostVAA withfees paid by user diff --git a/packages/bridge/public/home/main-logo.svg b/packages/bridge/public/home/main-logo.svg index 79faaf0..1153d67 100644 --- a/packages/bridge/public/home/main-logo.svg +++ b/packages/bridge/public/home/main-logo.svg @@ -1,50 +1,44 @@ - + - - - - - - + + + + + + - - - + + - + - + - + - + - + - + - + - + - - - - - diff --git a/packages/bridge/src/components/AppBar/index.less b/packages/bridge/src/components/AppBar/index.less index 0d8ac1c..004db18 100644 --- a/packages/bridge/src/components/AppBar/index.less +++ b/packages/bridge/src/components/AppBar/index.less @@ -6,7 +6,7 @@ header.ant-layout-header.App-Bar { width: 100%; background: transparent; display: flex; - justify-content: center; + justify-content: center !important; height: 80px; .nav-burger { @@ -30,6 +30,9 @@ header.ant-layout-header.App-Bar { justify-content: center; height: auto; align-items: center; + button.app-bar-item { + padding: 0; + } .app-bar-item { cursor: pointer; padding: 0 30px; @@ -69,7 +72,7 @@ header.ant-layout-header.App-Bar { max-width: 240px; height: 100%; flex-direction: column; - justify-content: flex-start; + justify-content: flex-start !important; padding: 0; .nav-burger { display: inline-block; diff --git a/packages/bridge/src/components/AppBar/index.tsx b/packages/bridge/src/components/AppBar/index.tsx index 51174b9..def20fb 100644 --- a/packages/bridge/src/components/AppBar/index.tsx +++ b/packages/bridge/src/components/AppBar/index.tsx @@ -43,15 +43,17 @@ export const AppBar = (props: { isRoot?: boolean }) => {
{!props.isRoot && (
- logo-bar + + logo-bar +
)}
Bridge
-
- FAQ -
+ {/*
*/} + {/* FAQ*/} + {/*
*/}
Proof-of-Assets
diff --git a/packages/bridge/src/components/AssetsTable/index.less b/packages/bridge/src/components/AssetsTable/index.less new file mode 100644 index 0000000..bbd02f1 --- /dev/null +++ b/packages/bridge/src/components/AssetsTable/index.less @@ -0,0 +1,45 @@ +@import "_colors"; + +#recent-tx-container { + max-width: 70%; + margin: auto; + padding-bottom: 70px; + .description-text { + color: @tungsten-60 + } + .ant-table-pagination.ant-pagination { + margin: 16px 100px; + } + .ant-table { + thead { + tr > th.ant-table-cell { + background-color: @tungsten-100; + border: none; + } + } + tbody > tr:nth-child(even) > td.ant-table-cell { + background-color: @tungsten-100; + border: none; + } + tbody > tr:nth-child(odd) > td.ant-table-cell { + background-color: @tungsten-50; + border: none; + } + } +} + +@media screen and (max-width: 900px) { + + #recent-tx-container { + max-width: 100%; + } +} + + +@media screen and (max-width: 1200px) { + + #recent-tx-container { + max-width: 90%; + } + +} diff --git a/packages/bridge/src/components/AssetsTable/index.tsx b/packages/bridge/src/components/AssetsTable/index.tsx new file mode 100644 index 0000000..b5c79dd --- /dev/null +++ b/packages/bridge/src/components/AssetsTable/index.tsx @@ -0,0 +1,134 @@ +import { Table } from 'antd'; +import React from 'react'; + +import './index.less'; +import { Link } from 'react-router-dom'; +import { TokenDisplay } from '../../components/TokenDisplay'; +import { toChainSymbol } from '../../contexts/chainPair'; +import { formatUSD, shortenAddress } from '@oyster/common'; +import { useWormholeAccounts } from '../../hooks/useWormholeAccounts'; + +export const AssetsTable = () => { + const { + loading: loadingLockedAccounts, + externalAssets, + totalInUSD, + } = useWormholeAccounts(); + + const columns = [ + { + title: 'Symbol', + dataIndex: 'symbol', + key: 'symbol', + render(text: string, record: any) { + return { + props: { + style: {}, + }, + children: ( + + + {record.logo && ( + + )}{' '} + {record.symbol} + + + ), + }; + }, + }, + { + title: 'Name', + dataIndex: 'name', + key: 'name', + }, + { + title: 'Amount', + dataIndex: 'amount', + key: 'amount', + }, + { + title: 'Amount ($)', + dataIndex: 'amountInUSD', + key: 'amountInUSD', + }, + { + title: 'Price', + dataIndex: 'price', + width: 100, + key: 'price', + render(text: string, record: any) { + return { + props: { + style: { textAlign: 'right' }, + }, + children: record.price ? formatUSD.format(record.price) : '--', + }; + }, + }, + { + title: 'Asset Address', + dataIndex: 'address', + key: 'address', + render(text: string, record: any) { + return { + props: { + style: {}, + }, + children: ( + + {shortenAddress(text, 6)} + + ), + }; + }, + }, + { + title: 'Wrapped Address', + dataIndex: 'mintKey', + key: 'mintKey', + render(text: string, record: any) { + return { + props: { + style: {}, + }, + children: ( + + {shortenAddress(text, 6)} + + ), + }; + }, + }, + ]; + + return ( +
+
Total Value Locked
+
+ {formatUSD.format(totalInUSD)} +
+ a.name)} + columns={columns} + loading={loadingLockedAccounts} + /> + + ); +}; diff --git a/packages/bridge/src/components/CurrentUserWalletBadge/index.tsx b/packages/bridge/src/components/CurrentUserWalletBadge/index.tsx new file mode 100644 index 0000000..be4358b --- /dev/null +++ b/packages/bridge/src/components/CurrentUserWalletBadge/index.tsx @@ -0,0 +1,32 @@ +import React from 'react'; + +import { useWallet, WALLET_PROVIDERS } from '@oyster/common'; +import { shortenAddress } from '@oyster/common'; + +export const CurrentUserWalletBadge = (props: { showDisconnect?: boolean }) => { + const { wallet, disconnect } = useWallet(); + + if (!wallet || !wallet.publicKey) { + return null; + } + + return ( +
+
+ {'icon'} p.name === 'Sollet')[0]?.icon} + style={{ marginRight: 8 }} + /> + {shortenAddress(`${wallet.publicKey}`)} + {props.showDisconnect && ( + disconnect()}> + X + + )} +
+
+ ); +}; diff --git a/packages/bridge/src/components/EthereumConnect/index.tsx b/packages/bridge/src/components/EthereumConnect/index.tsx index fbc14ea..c119e8d 100644 --- a/packages/bridge/src/components/EthereumConnect/index.tsx +++ b/packages/bridge/src/components/EthereumConnect/index.tsx @@ -56,7 +56,7 @@ export const EthereumConnect = () => { ) : ( )} diff --git a/packages/bridge/src/components/Input/input.tsx b/packages/bridge/src/components/Input/input.tsx index 216c957..5e83ac2 100644 --- a/packages/bridge/src/components/Input/input.tsx +++ b/packages/bridge/src/components/Input/input.tsx @@ -1,16 +1,18 @@ -import React, { useState } from 'react'; +import React, { useEffect, useState } from 'react'; import { ConnectButton, - CurrentUserWalletBadge, + CurrentUserBadge, NumericInput, + useMint, + useUserAccounts, useWallet, } from '@oyster/common'; import './style.less'; -import { ASSET_CHAIN } from '../../models/bridge/constants'; import { TokenSelectModal } from '../TokenSelectModal'; -import { chainToName } from '../../utils/assets'; +import { ASSET_CHAIN, chainToName } from '../../utils/assets'; import { TokenChain } from '../TokenDisplay/tokenChain'; import { EthereumConnect } from '../EthereumConnect'; +import { CurrentUserWalletBadge } from '../CurrentUserWalletBadge'; export function Input(props: { title: string; @@ -32,16 +34,14 @@ export function Input(props: {
{chainToName(props.chain)} - {typeof props.balance === 'number' && ( -
- props.onInputChange && props.onInputChange(props.balance) - } - > - {props.balance.toFixed(6)} -
- )} +
+ props.onInputChange && props.onInputChange(props.balance) + } + > + {props.balance?.toFixed(6)} +
button.ant-btn:not(.ant-dropdown-trigger) { + text-transform: uppercase; + color: white; + width: 166px; + font-size: 14px; + background: #E67828; + border-radius: 8px; + height: 40px; + } +} + .wallet-wrapper { display: flex; justify-content: center; diff --git a/packages/bridge/src/components/Layout/index.tsx b/packages/bridge/src/components/Layout/index.tsx index 4745cf9..02fe182 100644 --- a/packages/bridge/src/components/Layout/index.tsx +++ b/packages/bridge/src/components/Layout/index.tsx @@ -1,34 +1,18 @@ -import React, { useEffect, useState } from 'react'; +import React from 'react'; import './../../App.less'; import './index.less'; -import { Layout, Button, Popover } from 'antd'; -import { Link, useLocation } from 'react-router-dom'; +import { Layout } from 'antd'; +import { useLocation } from 'react-router-dom'; import { LABELS } from '../../constants'; import { AppBar } from '../AppBar'; -import Wormhole from '../Wormhole'; -import { Footer as AppFooter } from './../Footer'; -import { EthereumConnect } from '../EthereumConnect'; -import { useEthereum } from '../../contexts'; -import { Settings } from '@oyster/common'; -import { SettingOutlined } from '@ant-design/icons'; const { Header, Content, Footer } = Layout; export const AppLayout = React.memo((props: any) => { - const { connected, disconnect } = useEthereum(); const location = useLocation(); - const [wormholeReady, setWormholeReady] = useState(false); - - const paths: { [key: string]: string } = { - '/faucet': '7', - }; - const isRoot = location.pathname === '/'; - const current = - [...Object.keys(paths)].find(key => location.pathname.startsWith(key)) || - ''; return ( <>
@@ -40,9 +24,10 @@ export const AppLayout = React.memo((props: any) => { {props.children}
-
- © Solana Foundation -
+
diff --git a/packages/bridge/src/components/RecentTransactionsTable/index.less b/packages/bridge/src/components/RecentTransactionsTable/index.less new file mode 100644 index 0000000..c1e9885 --- /dev/null +++ b/packages/bridge/src/components/RecentTransactionsTable/index.less @@ -0,0 +1,54 @@ +@import "_colors"; + +#recent-tx-container { + max-width: 70%; + margin: auto; + padding-bottom: 70px; + .completed { + color: @surge-30; + } + .failed { + color: @tungsten-60; + } + .error { + color: #6E1080; + } + .description-text { + color: @tungsten-60 + } + .ant-table-pagination.ant-pagination { + margin: 16px 100px; + } + .ant-table { + thead { + tr > th.ant-table-cell { + background-color: @tungsten-100; + border: none; + } + } + tbody > tr:nth-child(even) > td.ant-table-cell { + background-color: @tungsten-100; + border: none; + } + tbody > tr:nth-child(odd) > td.ant-table-cell { + background-color: @tungsten-50; + border: none; + } + } +} + +@media screen and (max-width: 900px) { + + #recent-tx-container { + max-width: 100%; + } +} + + +@media screen and (max-width: 1200px) { + + #recent-tx-container { + max-width: 90%; + } + +} diff --git a/packages/bridge/src/components/RecentTransactionsTable/index.tsx b/packages/bridge/src/components/RecentTransactionsTable/index.tsx index 0c29740..86466f7 100644 --- a/packages/bridge/src/components/RecentTransactionsTable/index.tsx +++ b/packages/bridge/src/components/RecentTransactionsTable/index.tsx @@ -1,29 +1,56 @@ -import { Table } from 'antd'; -import React from 'react'; +import { Button, Table, notification } from 'antd'; +import React, { useEffect, useMemo, useState } from 'react'; + +import './index.less'; + +import TimeAgo from 'javascript-time-ago'; +import en from 'javascript-time-ago/locale/en'; + import { Link } from 'react-router-dom'; -import { useWormholeAccounts } from '../../hooks/useWormholeAccounts'; import { TokenDisplay } from '../../components/TokenDisplay'; import { toChainSymbol } from '../../contexts/chainPair'; -import { formatUSD, shortenAddress } from '@oyster/common'; +import { + formatUSD, + shortenAddress, + Identicon, + programIds, + TokenAccount, +} from '@oyster/common'; +import { useWormholeTransactions } from '../../hooks/useWormholeTransactions'; +import { ASSET_CHAIN } from '../../utils/assets'; +import { TokenChain } from '../TokenDisplay/tokenChain'; +import bs58 from 'bs58'; +import { SyncOutlined } from '@ant-design/icons'; +import { typeToIcon } from '../Transfer'; +import { ProgressUpdate } from '@solana/bridge-sdk'; +import { WormholeFactory } from '@solana/bridge-sdk'; +import { useEthereum } from '../../contexts'; +import { useBridge } from '../../contexts/bridge'; -export const RecentTransactionsTable = () => { - const { - loading: loadingLockedAccounts, - externalAssets, - totalInUSD, - } = useWormholeAccounts(); +TimeAgo.addDefaultLocale(en); +const timeAgo = new TimeAgo('en-US'); - const columns = [ +export const RecentTransactionsTable = (props: { + showUserTransactions?: boolean; + tokenAccounts: TokenAccount[]; +}) => { + const { loading: loadingTransfers, transfers } = useWormholeTransactions( + props.tokenAccounts, + ); + const { provider } = useEthereum(); + const bridge = useBridge(); + + const [completedVAAs, setCompletedVAAs] = useState>([]); + + const baseColumns = [ { - title: 'Symbol', - dataIndex: 'symbol', - key: 'symbol', + title: '', + dataIndex: 'logo', + key: 'logo', render(text: string, record: any) { return { - props: { - style: {}, - }, - children: ( + props: { style: {} }, + children: record.logo ? ( { {record.logo && ( - )}{' '} - {record.symbol} + )} + ) : ( +
+ + +
), }; }, }, { - title: 'Name', - dataIndex: 'name', - key: 'name', - }, - { - title: 'Amount', - dataIndex: 'amount', - key: 'amount', - }, - { - title: 'Amount ($)', - dataIndex: 'amountInUSD', - key: 'amountInUSD', - }, - { - title: 'Price', - dataIndex: 'price', - width: 100, - key: 'price', + title: 'Asset', + dataIndex: 'symbol', + key: 'symbol', render(text: string, record: any) { + const urlText = record.symbol || record.address; return { - props: { - style: { textAlign: 'right' }, - }, - children: record.price ? formatUSD.format(record.price) : '--', + props: { style: {} }, + children: + record.lockup.assetChain === ASSET_CHAIN.Solana ? ( + + {record.symbol || shortenAddress(urlText, 5)} + + ) : ( + + {record.symbol || shortenAddress(urlText, 5)} + + ), }; }, }, { - title: 'Asset Address', - dataIndex: 'address', - key: 'address', + title: 'Tokens moved', + dataIndex: 'amount', + key: 'amount', + }, + { + title: '$, value', + dataIndex: 'value', + key: 'value', render(text: string, record: any) { return { - props: { - style: {}, - }, + props: { style: {} }, + children: record.value ? formatUSD.format(record.value) : '--', + }; + }, + }, + { + title: 'TX hash', + dataIndex: 'txhash', + key: 'txhash', + render(text: string, record: any) { + return { + props: { style: {} }, children: ( {shortenAddress(text, 6)} @@ -87,41 +141,208 @@ export const RecentTransactionsTable = () => { }, }, { - title: 'Wrapped Address', - dataIndex: 'mintKey', - key: 'mintKey', + title: 'Date', + dataIndex: 'date', + key: 'date', render(text: string, record: any) { return { - props: { - style: {}, - }, - children: ( - - {shortenAddress(text, 6)} - - ), + props: { style: {} }, + children: timeAgo.format(new Date(record.date * 1000)), }; }, }, ]; + + const userColumns = useMemo( + () => [ + ...baseColumns, + { + title: 'Status', + dataIndex: 'status', + key: 'status', + render(text: string, record: any) { + const status = + completedVAAs.indexOf(record.txhash) > 0 + ? 'Completed' + : record.status; + return { + props: { style: {} }, + children: ( + <> + + {status} + + {status === 'Failed' ? ( +
a.name)} - columns={columns} - loading={loadingLockedAccounts} + dataSource={transfers.sort((a, b) => b.date - a.date)} + columns={userColumns} + loading={loadingTransfers} /> ); diff --git a/packages/bridge/src/components/TokenDisplay/index.tsx b/packages/bridge/src/components/TokenDisplay/index.tsx index dff41f5..04dbcdd 100644 --- a/packages/bridge/src/components/TokenDisplay/index.tsx +++ b/packages/bridge/src/components/TokenDisplay/index.tsx @@ -3,7 +3,7 @@ import { TokenInfo } from '@solana/spl-token-registry'; import { debug } from 'console'; import React from 'react'; import { useEthereum } from '../../contexts'; -import { ASSET_CHAIN } from '../../models/bridge/constants'; +import { ASSET_CHAIN } from '../../utils/assets'; import './style.less'; import { TokenChain } from './tokenChain'; diff --git a/packages/bridge/src/components/TokenDisplay/tokenChain.tsx b/packages/bridge/src/components/TokenDisplay/tokenChain.tsx index f8cece1..c98617b 100644 --- a/packages/bridge/src/components/TokenDisplay/tokenChain.tsx +++ b/packages/bridge/src/components/TokenDisplay/tokenChain.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { ASSET_CHAIN } from '../../models/bridge/constants'; +import { ASSET_CHAIN } from '../../utils/assets'; export const TokenChain = (props: { chain?: ASSET_CHAIN; diff --git a/packages/bridge/src/components/TokenSelectModal/index.tsx b/packages/bridge/src/components/TokenSelectModal/index.tsx index 585e7b7..c5c1afc 100644 --- a/packages/bridge/src/components/TokenSelectModal/index.tsx +++ b/packages/bridge/src/components/TokenSelectModal/index.tsx @@ -6,9 +6,9 @@ import './style.less'; import { Input, Modal } from 'antd'; import { useEthereum } from '../../contexts'; import { TokenDisplay } from '../TokenDisplay'; -import { ASSET_CHAIN } from '../../models/bridge/constants'; +import { ASSET_CHAIN } from '../../utils/assets'; import { useConnectionConfig } from '@oyster/common'; -import { filterModalSolTokens } from '../../utils/assets'; +import { filterModalEthTokens, filterModalSolTokens } from '../../utils/assets'; export const TokenSelectModal = (props: { onSelectToken: (token: string) => void; @@ -24,7 +24,10 @@ export const TokenSelectModal = (props: { const inputRef = useRef(null); const tokens = useMemo( - () => [...ethTokens, ...filterModalSolTokens(solTokens)], + () => [ + ...filterModalEthTokens(ethTokens), + ...filterModalSolTokens(solTokens), + ], [ethTokens, solTokens], ); @@ -33,7 +36,8 @@ export const TokenSelectModal = (props: { return tokens.filter(token => { return ( (token.tags?.indexOf('longList') || -1) < 0 && - token.symbol.includes(search.toUpperCase()) + (token.symbol.toLowerCase().includes(search.toLowerCase()) || + token.name.toLowerCase().includes(search.toLowerCase())) ); }); } diff --git a/packages/bridge/src/components/Transfer/index.tsx b/packages/bridge/src/components/Transfer/index.tsx index 46ad5d9..57924ae 100644 --- a/packages/bridge/src/components/Transfer/index.tsx +++ b/packages/bridge/src/components/Transfer/index.tsx @@ -1,36 +1,24 @@ -import React, { useEffect, useState } from 'react'; +import React, { useEffect, useMemo, useState } from 'react'; import { notification, Spin, Button } from 'antd'; -import { - contexts, - ConnectButton, - programIds, - notify, - cache, - useUserAccounts, -} from '@oyster/common'; +import { contexts, TokenAccount, useUserAccounts } from '@oyster/common'; import { Input } from '../Input'; import './style.less'; import { ASSET_CHAIN, chainToName } from '../../utils/assets'; import { - bridgeAuthorityKey, displayBalance, fromSolana, ProgressUpdate, toSolana, TransferRequest, - wrappedAssetMintKey, -} from '../../models/bridge'; +} from '@solana/bridge-sdk'; import { useEthereum } from '../../contexts'; import { TokenDisplay } from '../TokenDisplay'; -import { WrappedAssetFactory } from '../../contracts/WrappedAssetFactory'; -import { WormholeFactory } from '../../contracts/WormholeFactory'; -import BN from 'bn.js'; import { useTokenChainPairState } from '../../contexts/chainPair'; import { LABELS } from '../../constants'; import { useCorrectNetwork } from '../../hooks/useCorrectNetwork'; -import { BigNumber } from 'ethers/utils'; import { RecentTransactionsTable } from '../RecentTransactionsTable'; +import { useBridge } from '../../contexts/bridge'; const { useConnection } = contexts.Connection; const { useWallet } = contexts.Wallet; @@ -53,8 +41,10 @@ export const typeToIcon = (type: string, isLast: boolean) => { export const Transfer = () => { const connection = useConnection(); + const bridge = useBridge(); const { wallet, connected } = useWallet(); const { provider, tokenMap } = useEthereum(); + const { userAccounts } = useUserAccounts(); const hasCorrespondingNetworks = useCorrectNetwork(); const { A, @@ -63,6 +53,7 @@ export const Transfer = () => { setMintAddress, setLastTypedAccount, } = useTokenChainPairState(); + const [request, setRequest] = useState({ from: ASSET_CHAIN.Ethereum, to: ASSET_CHAIN.Solana, @@ -90,7 +81,13 @@ export const Transfer = () => { to: B.chain, info: A.info, }); - }, [A, B, mintAddress]); + }, [A, B, mintAddress, A.info]); + + const tokenAccounts = useMemo( + () => + userAccounts.filter(u => u.info.mint.toBase58() === request.info?.mint), + [request.info?.mint], + ); return ( <> @@ -105,7 +102,9 @@ export const Transfer = () => { onChain={(chain: ASSET_CHAIN) => { const from = A.chain; A.setChain(chain); - B.setChain(from); + if (B.chain === chain) { + B.setChain(from); + } }} onInputChange={amount => { setLastTypedAccount(A.chain); @@ -139,7 +138,9 @@ export const Transfer = () => { onChain={(chain: ASSET_CHAIN) => { const to = B.chain; B.setChain(chain); - A.setChain(to); + if (A.chain === chain) { + A.setChain(to); + } }} onInputChange={amount => { setLastTypedAccount(B.chain); @@ -184,6 +185,7 @@ export const Transfer = () => { setActiveSteps(steps); }, + bridge, ); } @@ -293,7 +295,7 @@ export const Transfer = () => { : LABELS.TRANSFER : LABELS.SET_CORRECT_WALLET_NETWORK} - + ); }; diff --git a/packages/bridge/src/components/Transfer/style.less b/packages/bridge/src/components/Transfer/style.less index 0324ff0..e9825b9 100644 --- a/packages/bridge/src/components/Transfer/style.less +++ b/packages/bridge/src/components/Transfer/style.less @@ -22,13 +22,35 @@ .exchange-card { position: relative; - max-width: calc(100% - 460px); + max-width: 900px; width: 100%; margin: 167px auto 150px auto; display: flex; justify-content: space-between; } +.action-button{ + width: 240px; + height: 64px; + + border-radius: 12px; + border: none; + background-color: @surge-20 !important; + color: white !important; + font-weight: bold; + font-size: 18px; + line-height: 23px; + text-align: center; + letter-spacing: 0.04em; + text-transform: uppercase; + font-feature-settings: 'ss02' on; + +} + +.action-button:hover { + background-color: @surge-30 !important; +} + .transfer-button{ display: flex; diff --git a/packages/bridge/src/contexts/bridge.tsx b/packages/bridge/src/contexts/bridge.tsx index 5993077..1d778c0 100644 --- a/packages/bridge/src/contexts/bridge.tsx +++ b/packages/bridge/src/contexts/bridge.tsx @@ -1,5 +1,5 @@ import React, { createContext, FunctionComponent, useContext } from 'react'; -import { SolanaBridge } from '../core'; +import { SolanaBridge } from '@solana/bridge-sdk'; import { useConnection, useConnectionConfig, @@ -13,12 +13,15 @@ export const BridgeProvider: FunctionComponent = ({ children }) => { const connection = useConnection(); const programs = utils.programIds(); - /// let bridge = new SolanaBridge(endpoint, connection, programs.wormhole.pubkey, programs.token); + let bridge = new SolanaBridge( + endpoint, + connection, + programs.wormhole.pubkey, + programs.token, + ); return ( - - {children} - + {children} ); }; diff --git a/packages/bridge/src/contexts/chainPair.tsx b/packages/bridge/src/contexts/chainPair.tsx index 92192b5..e7da0d4 100644 --- a/packages/bridge/src/contexts/chainPair.tsx +++ b/packages/bridge/src/contexts/chainPair.tsx @@ -14,16 +14,24 @@ import { useUserAccounts, } from '@oyster/common'; import { TokenInfo } from '@solana/spl-token-registry'; -import { ASSET_CHAIN, filterModalSolTokens } from '../utils/assets'; +import { + ASSET_CHAIN, + filterModalEthTokens, + filterModalSolTokens, +} from '../utils/assets'; import { useEthereum } from './ethereum'; -import { BigNumber } from 'ethers/utils'; -import { WrappedAssetFactory } from '../contracts/WrappedAssetFactory'; -import { WormholeFactory } from '../contracts/WormholeFactory'; +import { BigNumber } from 'bignumber.js'; +import { AssetMeta, WrappedAssetFactory } from '@solana/bridge-sdk'; +import { WormholeFactory } from '@solana/bridge-sdk'; import { bridgeAuthorityKey, TransferRequestInfo, wrappedAssetMintKey, -} from '../models/bridge'; +} from '@solana/bridge-sdk'; +import { useBridge } from './bridge'; +import { PublicKey } from '@solana/web3.js'; +import { ethers } from 'ethers'; + export interface TokenChainContextState { info?: TransferRequestInfo; @@ -91,11 +99,22 @@ export const useCurrencyLeg = (mintAddress: string) => { const [chain, setChain] = useState(ASSET_CHAIN.Ethereum); const [info, setInfo] = useState(); const { userAccounts } = useUserAccounts(); + const bridge = useBridge(); const { provider, tokens: ethTokens } = useEthereum(); const { tokens: solTokens } = useConnectionConfig(); const connection = useConnection(); - + const defaultCoinInfo = { + address: '', + name: '', + balance: new BigNumber(0), + decimals: 0, + allowance: new ethers.utils.BigNumber(0), + isWrapped: false, + chainID: 0, + assetAddress: new Buffer(0), + mint: '', + }; useEffect(() => { if (!provider || !connection) { return; @@ -103,31 +122,78 @@ export const useCurrencyLeg = (mintAddress: string) => { (async () => { const ethToken = ethTokens.find(t => t.address === mintAddress); - const solToken = solTokens.find(t => t.address === mintAddress); + let solToken = solTokens.find(t => t.address === mintAddress); + let mintKeyAddress = ''; + let symbol = ''; + let decimals = 0; - // eth assets on eth chain - // eth asset on sol chain - // sol asset on eth chain - // sol asset on sol chain + //console.log({ chain, solToken, ethToken }); + if (chain === ASSET_CHAIN.Solana) { + if (!solToken && ethToken) { + try { + const bridgeId = programIds().wormhole.pubkey; + const authority = await bridgeAuthorityKey(bridgeId); + const assetAddress = Buffer.from(ethToken.address.slice(2), 'hex'); + const meta: AssetMeta = { + decimals: Math.min(ethToken.decimals, 9), + address: assetAddress, + chain: ASSET_CHAIN.Ethereum, + }; + const mintKey = await wrappedAssetMintKey( + bridgeId, + authority, + meta, + ); + if (mintKey) { + mintKeyAddress = mintKey.toBase58(); + solToken = solTokens.find(t => t.address === mintKeyAddress); + if (!solToken) { + symbol = ethToken.symbol; + decimals = ethToken.decimals; + } + } else { + setInfo(defaultCoinInfo); + return; + } + } catch { + setInfo(defaultCoinInfo); + return; + } + } + if (!solToken && (!symbol || !mintKeyAddress || !decimals)) { + setInfo(defaultCoinInfo); + return; + } + const currentAccount = userAccounts?.find( + a => a.info.mint.toBase58() === (solToken?.address || mintKeyAddress), + ); + const assetMeta = await bridge?.fetchAssetMeta( + new PublicKey(solToken?.address || mintKeyAddress), + ); - let ethAddress: string = ''; - if (solToken) { - // let signer = provider.getSigner(); - // let e = WrappedAssetFactory.connect(asset, provider); - // let addr = await signer.getAddress(); - // let decimals = await e.decimals(); - // let symbol = await e.symbol(); - - // TODO: checked if mint is wrapped mint from eth... - - const accounts = userAccounts - .filter(a => a.info.mint.toBase58() === solToken.address) - .sort((a, b) => a.info.amount.toNumber() - b.info.amount.toNumber()); - - console.log(accounts); + if (!assetMeta || !currentAccount) { + setInfo(defaultCoinInfo); + return; + } + let info = { + address: currentAccount.pubkey.toBase58(), + name: solToken?.symbol || symbol, + balance: new BigNumber(currentAccount?.info.amount.toNumber() || 0), + allowance: new ethers.utils.BigNumber(0), + decimals: solToken?.decimals || decimals, + isWrapped: assetMeta.chain != ASSET_CHAIN.Solana, + chainID: assetMeta.chain, + assetAddress: assetMeta.address, + mint: solToken?.address || mintKeyAddress, + }; + setInfo(info); } - if (ethToken) { + if (chain === ASSET_CHAIN.Ethereum) { + if (!ethToken) { + setInfo(defaultCoinInfo); + return; + } let signer = provider.getSigner(); let e = WrappedAssetFactory.connect(mintAddress, provider); let addr = await signer.getAddress(); @@ -158,7 +224,9 @@ export const useCurrencyLeg = (mintAddress: string) => { } if (chain === ASSET_CHAIN.Ethereum) { - info.balance = await e.balanceOf(addr); + info.balance = new BigNumber( + new ethers.utils.BigNumber(await e.balanceOf(addr)).toString(), + ); } else { // TODO: get balance on other chains for assets that came from eth @@ -170,12 +238,9 @@ export const useCurrencyLeg = (mintAddress: string) => { address: info.assetAddress, chain: info.chainID, }); - - console.log(mint.toBase58()); } - console.log(info); - + //console.log({ info }); setInfo(info); } })(); @@ -190,16 +255,13 @@ export const useCurrencyLeg = (mintAddress: string) => { userAccounts, ]); - return useMemo( - () => ({ - amount: amount, - setAmount: setAmount, - chain: chain, - setChain: setChain, - info, - }), - [amount, setAmount, chain, setChain], - ); + return { + amount: amount, + setAmount: setAmount, + chain: chain, + setChain: setChain, + info, + }; }; export function TokenChainPairProvider({ children = null as any }) { @@ -223,7 +285,10 @@ export function TokenChainPairProvider({ children = null as any }) { const setChainB = quote.setChain; const tokens = useMemo( - () => [...ethTokens, ...filterModalSolTokens(solTokens)], + () => [ + ...filterModalEthTokens(ethTokens), + ...filterModalSolTokens(solTokens), + ], [ethTokens, solTokens], ); @@ -249,7 +314,7 @@ export function TokenChainPairProvider({ children = null as any }) { return; } let { defaultChain, defaultToken } = getDefaultTokens( - ethTokens, + tokens, location.search, ); if (!defaultToken || !defaultChain) { @@ -269,15 +334,7 @@ export function TokenChainPairProvider({ children = null as any }) { ); // mintAddressA and mintAddressB are not included here to prevent infinite loop // eslint-disable-next-line - }, [ - location, - location.search, - location.pathname, - setMintAddress, - tokens, - setChainA, - setChainB, - ]); + }, [location, location.search, location.pathname, tokens]); const calculateDependent = useCallback(async () => { if (mintAddress) { diff --git a/packages/bridge/src/contexts/ethereum.tsx b/packages/bridge/src/contexts/ethereum.tsx index 62e2d13..6efd80c 100644 --- a/packages/bridge/src/contexts/ethereum.tsx +++ b/packages/bridge/src/contexts/ethereum.tsx @@ -7,13 +7,7 @@ import React, { useMemo, useState, } from 'react'; -// @ts-ignore -import { useWallet as useEthereumWallet } from 'use-wallet'; -// @ts-ignore -import WalletConnectProvider from '@walletconnect/web3-provider'; -// @ts-ignore -import Fortmatic from 'fortmatic'; import { useWallet, useLocalStorageState } from '@oyster/common'; import { WalletAdapter } from '@solana/wallet-base'; import { TokenList, TokenInfo } from '@uniswap/token-lists'; @@ -230,6 +224,7 @@ export const EthereumProvider: FunctionComponent = ({ children }) => { return ( +
How does Wormhole Work?
+

+ Wormhole allows existing projects, platforms, and communities to + move tokenized assets seamlessly across blockchains to benefit + from Solana’s high speed and low cost. Wormhole does this by + wrapping ERC-20 tokens, which are then usable in Solana’s low-cost + defi ecosystem. +

+ + +
+ +
+ + + + + + + +
+ How can I integrate Wormhole into my wallet or dapp? +
+

+ Wormhole is an open-source project accessible to all. +

+ + + + ); }; diff --git a/packages/bridge/src/views/home/index.less b/packages/bridge/src/views/home/index.less index 5f59027..16c61bb 100644 --- a/packages/bridge/src/views/home/index.less +++ b/packages/bridge/src/views/home/index.less @@ -25,6 +25,18 @@ section.ant-layout { width: 25px; height: 21px; } +.logo-title { + /* SOLANA <-> ETHEREUM BRIDGE */ + background: linear-gradient(90deg, #DC1FFF 11.29%, #4DA9FF 51.42%, #00CC82 93.23%); + -webkit-background-clip: text; + -webkit-text-fill-color: transparent; + font-size: 16px; + line-height: 160%; + text-align: center; + letter-spacing: 0.8em; + text-transform: uppercase; + margin-bottom: 90px; +} .home-subtitle { font-size: 32px; @@ -39,6 +51,7 @@ section.ant-layout { .home-container { width: 100%; + background-color: #06101a; #how-it-works-container { display: flex; flex-direction: column; @@ -54,9 +67,9 @@ section.ant-layout { .home-description { display: flex; flex-direction: row; - justify-content: space-evenly; - max-width: 90%; + width: 90%; margin: auto; + justify-content: space-evenly; .home-description-item { padding: 0 30px 0 30px; @@ -117,7 +130,7 @@ section.ant-layout { font-size: 16px; line-height: 160%; width: auto; - margin: 3px 20px 30px 20px; + margin: 3px 20px 40px 20px; } & > div:first-child { margin-bottom: 120px; @@ -141,7 +154,6 @@ footer.ant-layout-footer { .wormhole-bg { background-image: url('/home/background.svg'); background-size: 100% auto; - background-color: #06101a; background-repeat: no-repeat; } diff --git a/packages/bridge/src/views/home/index.tsx b/packages/bridge/src/views/home/index.tsx index 36ceeef..50c24fc 100644 --- a/packages/bridge/src/views/home/index.tsx +++ b/packages/bridge/src/views/home/index.tsx @@ -1,117 +1,15 @@ -import { Table, Col, Row, Statistic, Button } from 'antd'; import anime from 'animejs'; -import React, { useMemo } from 'react'; -import { GUTTER } from '../../constants'; -import { formatNumber, formatUSD, shortenAddress } from '@oyster/common'; +import React from 'react'; +import { formatUSD, shortenAddress } from '@oyster/common'; import './itemStyle.less'; import './index.less'; import { Link } from 'react-router-dom'; import { useWormholeAccounts } from '../../hooks/useWormholeAccounts'; import { TokenDisplay } from '../../components/TokenDisplay'; import { toChainSymbol } from '../../contexts/chainPair'; +import { AssetsTable } from '../../components/AssetsTable'; export const HomeView = () => { - const { - loading: loadingLockedAccounts, - externalAssets, - totalInUSD, - } = useWormholeAccounts(); - - const columns = [ - { - title: 'Symbol', - dataIndex: 'symbol', - key: 'symbol', - render(text: string, record: any) { - return { - props: { - style: {}, - }, - children: ( - - - {record.logo && ( - - )}{' '} - {record.symbol} - - - ), - }; - }, - }, - { - title: 'Name', - dataIndex: 'name', - key: 'name', - }, - { - title: 'Amount', - dataIndex: 'amount', - key: 'amount', - }, - { - title: 'Amount ($)', - dataIndex: 'amountInUSD', - key: 'amountInUSD', - }, - { - title: 'Price', - dataIndex: 'price', - width: 100, - key: 'price', - render(text: string, record: any) { - return { - props: { - style: { textAlign: 'right' }, - }, - children: record.price ? formatUSD.format(record.price) : '--', - }; - }, - }, - { - title: 'Asset Address', - dataIndex: 'address', - key: 'address', - render(text: string, record: any) { - return { - props: { - style: {}, - }, - children: ( - - {shortenAddress(text, 6)} - - ), - }; - }, - }, - { - title: 'Wrapped Address', - dataIndex: 'mintKey', - key: 'mintKey', - render(text: string, record: any) { - return { - props: { - style: {}, - }, - children: ( - - {shortenAddress(text, 6)} - - ), - }; - }, - }, - ]; const handleDownArrow = () => { const scrollTo = document.getElementById('how-it-works-container'); const scrollElement = @@ -127,14 +25,18 @@ export const HomeView = () => { }; return ( <> -
-
+
+
+
+ {' '} + SOLANA <-> ETHEREUM BRIDGE +
- A decentralized and bi-directional bridge for -
ERC-20 and SPL tokens + Easily move any tokens between Ethereum and Solana
with + Wormhole’s bi-directional bridge
@@ -158,51 +60,25 @@ export const HomeView = () => {
Bridge in any direction
-
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis - nisi at praesent sed sollicitudin ullamcorper malesuada in. - Molestie sed morbi vitae in amet ultrices. -
+
Staking & Validation
-
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis - nisi at praesent sed sollicitudin ullamcorper malesuada in. - Molestie sed morbi vitae in amet ultrices. -
+
Layers and Capabilities
-
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis - nisi at praesent sed sollicitudin ullamcorper malesuada in. - Molestie sed morbi vitae in amet ultrices. -
+
-
-
Recent Transactions
-
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. -
-
a.name)} - columns={columns} - loading={loadingLockedAccounts} - /> - + ); diff --git a/packages/bridge/src/views/proof-of-assets/index.less b/packages/bridge/src/views/proof-of-assets/index.less index e69de29..6e546ca 100644 --- a/packages/bridge/src/views/proof-of-assets/index.less +++ b/packages/bridge/src/views/proof-of-assets/index.less @@ -0,0 +1,3 @@ +div:not(.home-container) > #recent-tx-container { + margin-top: 150px; +} diff --git a/packages/bridge/src/views/proof-of-assets/index.tsx b/packages/bridge/src/views/proof-of-assets/index.tsx index ea227a9..02e0076 100644 --- a/packages/bridge/src/views/proof-of-assets/index.tsx +++ b/packages/bridge/src/views/proof-of-assets/index.tsx @@ -1,12 +1,15 @@ import React from 'react'; import './index.less'; +import { AssetsTable } from '../../components/AssetsTable'; export const ProofOfAssetsView = () => { return (
+ > + + ); }; diff --git a/packages/bridge/src/views/transfer/index.tsx b/packages/bridge/src/views/transfer/index.tsx index ae298ad..568d961 100644 --- a/packages/bridge/src/views/transfer/index.tsx +++ b/packages/bridge/src/views/transfer/index.tsx @@ -1,6 +1,5 @@ import React from 'react'; import './index.less'; -import { Card } from 'antd'; import { Transfer } from '../../components/Transfer'; export const TransferView = () => { diff --git a/packages/bridge/src/wallet-adapters/wallet-connect.tsx b/packages/bridge/src/wallet-adapters/wallet-connect.tsx index 3c99514..a513428 100644 --- a/packages/bridge/src/wallet-adapters/wallet-connect.tsx +++ b/packages/bridge/src/wallet-adapters/wallet-connect.tsx @@ -1,6 +1,5 @@ import EventEmitter from 'eventemitter3'; import { PublicKey, Transaction } from '@solana/web3.js'; -import { notify } from '@oyster/common'; import { WalletAdapter } from '@solana/wallet-base'; import { ethers } from 'ethers'; import WalletConnectProvider from '@walletconnect/web3-provider'; diff --git a/packages/bridge/tsconfig.json b/packages/bridge/tsconfig.json index 7420e1f..8ae8d0b 100644 --- a/packages/bridge/tsconfig.json +++ b/packages/bridge/tsconfig.json @@ -1,6 +1,7 @@ { "compilerOptions": { - "target": "es5", + "module": "esnext", + "target": "es2019", "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "skipLibCheck": true, @@ -9,14 +10,13 @@ "strict": true, "forceConsistentCasingInFileNames": true, "noFallthroughCasesInSwitch": true, - "module": "esnext", - "moduleResolution": "node", "resolveJsonModule": true, "isolatedModules": true, "downlevelIteration": true, "noEmit": true, "jsx": "react", - "typeRoots": ["types", "../../types", "../../node_modules/@types"] + "typeRoots": ["types", "../../types", "../../node_modules/@types"], + "moduleResolution": "node" }, "include": ["src"] } diff --git a/packages/common/package.json b/packages/common/package.json index c2343ee..2f90825 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -25,12 +25,13 @@ "prepare": "run-s clean build" }, "dependencies": { - "@solana/wallet-base": "0.0.1", "@project-serum/serum": "^0.13.11", "@project-serum/sol-wallet-adapter": "^0.1.4", "@solana/spl-token": "0.0.13", "@solana/spl-token-swap": "0.1.0", - "@solana/web3.js": "^0.86.2", + "@solana/wallet-base": "0.0.1", + "@solana/wallet-ledger": "0.0.1", + "@solana/web3.js": "^1.5.0", "@testing-library/jest-dom": "^4.2.4", "@testing-library/react": "^9.5.0", "@testing-library/user-event": "^7.2.1", @@ -39,7 +40,9 @@ "@types/react-router-dom": "^5.1.6", "@welldone-software/why-did-you-render": "^6.0.5", "antd": "^4.6.6", + "bignumber.js": "^9.0.1", "bn.js": "^5.1.3", + "borsh": "^0.3.1", "bs58": "^4.0.1", "buffer-layout": "^1.2.0", "eventemitter3": "^4.0.7", @@ -57,9 +60,9 @@ "@types/jest": "^24.9.1", "@types/node": "^12.12.62", "arweave-deploy": "^1.9.1", - "less-watch-compiler": "v1.14.6", - "less": "4.1.1", "gh-pages": "^3.1.0", + "less": "4.1.1", + "less-watch-compiler": "v1.14.6", "prettier": "^2.1.2" }, "files": [ diff --git a/packages/common/src/actions/auction.ts b/packages/common/src/actions/auction.ts new file mode 100644 index 0000000..c972b07 --- /dev/null +++ b/packages/common/src/actions/auction.ts @@ -0,0 +1,630 @@ +import { + AccountInfo, + PublicKey, + SystemProgram, + SYSVAR_CLOCK_PUBKEY, + SYSVAR_RENT_PUBKEY, + TransactionInstruction, +} from '@solana/web3.js'; +import { programIds } from '../utils/ids'; +import { deserializeBorsh } from './../utils/borsh'; +import { serialize } from 'borsh'; +import BN from 'bn.js'; +import { AccountParser, cache } from '../contexts'; + +export const AUCTION_PREFIX = 'auction'; +export const METADATA = 'metadata'; + +export enum AuctionState { + Created = 0, + Started, + Ended, +} + +export enum BidStateType { + EnglishAuction = 0, + OpenEdition = 1, +} + +export class Bid { + key: PublicKey; + amount: BN; + constructor(args: { key: PublicKey; amount: BN }) { + this.key = args.key; + this.amount = args.amount; + } +} + +export class BidState { + type: BidStateType; + bids: Bid[]; + max: BN; + + public getWinnerIndex(bidder: PublicKey): number | null { + if (!this.bids) return null; + console.log( + 'bids', + this.bids.map(b => b.key.toBase58()), + bidder.toBase58(), + ); + const index = this.bids.findIndex( + b => b.key.toBase58() == bidder.toBase58(), + ); + if (index != -1) return index; + else return null; + } + + constructor(args: { type: BidStateType; bids: Bid[]; max: BN }) { + this.type = args.type; + this.bids = args.bids; + this.max = args.max; + } +} + +export const AuctionParser: AccountParser = ( + pubkey: PublicKey, + account: AccountInfo, +) => ({ + pubkey, + account, + info: decodeAuction(account.data), +}); + +export const decodeAuction = (buffer: Buffer) => { + return deserializeBorsh(AUCTION_SCHEMA, AuctionData, buffer) as AuctionData; +}; + +export const BidderPotParser: AccountParser = ( + pubkey: PublicKey, + account: AccountInfo, +) => ({ + pubkey, + account, + info: decodeBidderPot(account.data), +}); + +export const decodeBidderPot = (buffer: Buffer) => { + return deserializeBorsh(AUCTION_SCHEMA, BidderPot, buffer) as BidderPot; +}; + +export const BidderMetadataParser: AccountParser = ( + pubkey: PublicKey, + account: AccountInfo, +) => ({ + pubkey, + account, + info: decodeBidderMetadata(account.data), +}); + +export const decodeBidderMetadata = (buffer: Buffer) => { + return deserializeBorsh( + AUCTION_SCHEMA, + BidderMetadata, + buffer, + ) as BidderMetadata; +}; + +export const BASE_AUCTION_DATA_SIZE = 32 + 32 + 32 + 8 + 8 + 1 + 9 + 9 + 9 + 9; + +export class AuctionData { + /// Pubkey of the authority with permission to modify this auction. + authority: PublicKey; + /// Pubkey of the resource being bid on. + resource: PublicKey; + /// Token mint for the SPL token being used to bid + tokenMint: PublicKey; + /// The time the last bid was placed, used to keep track of auction timing. + lastBid: BN | null; + /// Slot time the auction was officially ended by. + endedAt: BN | null; + /// End time is the cut-off point that the auction is forced to end by. + endAuctionAt: BN | null; + /// Gap time is the amount of time in slots after the previous bid at which the auction ends. + auctionGap: BN | null; + /// The state the auction is in, whether it has started or ended. + state: AuctionState; + /// Auction Bids, each user may have one bid open at a time. + bidState: BidState; + + /// Used for precalculation on the front end, not a backend key + auctionManagerKey?: PublicKey; + /// Used for precalculation on the front end, not a backend key + bidRedemptionKey?: PublicKey; + + constructor(args: { + authority: PublicKey; + resource: PublicKey; + tokenMint: PublicKey; + lastBid: BN | null; + endedAt: BN | null; + endAuctionAt: BN | null; + auctionGap: BN | null; + state: AuctionState; + bidState: BidState; + }) { + this.authority = args.authority; + this.resource = args.resource; + this.tokenMint = args.tokenMint; + this.lastBid = args.lastBid; + this.endedAt = args.endedAt; + this.endAuctionAt = args.endAuctionAt; + this.auctionGap = args.auctionGap; + this.state = args.state; + this.bidState = args.bidState; + } +} + +export const BIDDER_METADATA_LEN = 32 + 32 + 8 + 8 + 1; +export class BidderMetadata { + // Relationship with the bidder who's metadata this covers. + bidderPubkey: PublicKey; + // Relationship with the auction this bid was placed on. + auctionPubkey: PublicKey; + // Amount that the user bid. + lastBid: BN; + // Tracks the last time this user bid. + lastBidTimestamp: BN; + // Whether the last bid the user made was cancelled. This should also be enough to know if the + // user is a winner, as if cancelled it implies previous bids were also cancelled. + cancelled: boolean; + constructor(args: { + bidderPubkey: PublicKey; + auctionPubkey: PublicKey; + lastBid: BN; + lastBidTimestamp: BN; + cancelled: boolean; + }) { + this.bidderPubkey = args.bidderPubkey; + this.auctionPubkey = args.auctionPubkey; + this.lastBid = args.lastBid; + this.lastBidTimestamp = args.lastBidTimestamp; + this.cancelled = args.cancelled; + } +} + +export const BIDDER_POT_LEN = 32 + 32 + 32; +export class BidderPot { + /// Points at actual pot that is a token account + bidderPot: PublicKey; + bidderAct: PublicKey; + auctionAct: PublicKey; + constructor(args: { + bidderPot: PublicKey; + bidderAct: PublicKey; + auctionAct: PublicKey; + }) { + this.bidderPot = args.bidderPot; + this.bidderAct = args.bidderAct; + this.auctionAct = args.auctionAct; + } +} + +export enum WinnerLimitType { + Unlimited = 0, + Capped = 1, +} + +export class WinnerLimit { + type: WinnerLimitType; + usize: BN; + constructor(args: { type: WinnerLimitType; usize: BN }) { + this.type = args.type; + this.usize = args.usize; + } +} + +class CreateAuctionArgs { + instruction: number = 0; + /// How many winners are allowed for this auction. See AuctionData. + winners: WinnerLimit; + /// End time is the cut-off point that the auction is forced to end by. See AuctionData. + endAuctionAt: BN | null; + /// Gap time is how much time after the previous bid where the auction ends. See AuctionData. + auctionGap: BN | null; + /// Token mint for the SPL token used for bidding. + tokenMint: PublicKey; + /// Authority + authority: PublicKey; + /// The resource being auctioned. See AuctionData. + resource: PublicKey; + + constructor(args: { + winners: WinnerLimit; + endAuctionAt: BN | null; + auctionGap: BN | null; + tokenMint: PublicKey; + authority: PublicKey; + resource: PublicKey; + }) { + this.winners = args.winners; + this.endAuctionAt = args.endAuctionAt; + this.auctionGap = args.auctionGap; + this.tokenMint = args.tokenMint; + this.authority = args.authority; + this.resource = args.resource; + } +} + +class StartAuctionArgs { + instruction: number = 1; + resource: PublicKey; + + constructor(args: { resource: PublicKey }) { + this.resource = args.resource; + } +} + +class PlaceBidArgs { + instruction: number = 2; + resource: PublicKey; + amount: BN; + + constructor(args: { resource: PublicKey; amount: BN }) { + this.resource = args.resource; + this.amount = args.amount; + } +} + +export const AUCTION_SCHEMA = new Map([ + [ + CreateAuctionArgs, + { + kind: 'struct', + fields: [ + ['instruction', 'u8'], + ['winners', WinnerLimit], + ['endAuctionAt', { kind: 'option', type: 'u64' }], + ['auctionGap', { kind: 'option', type: 'u64' }], + ['tokenMint', 'pubkey'], + ['authority', 'pubkey'], + ['resource', 'pubkey'], + ], + }, + ], + [ + WinnerLimit, + { + kind: 'struct', + fields: [ + ['type', 'u8'], + ['usize', 'u64'], + ], + }, + ], + [ + StartAuctionArgs, + { + kind: 'struct', + fields: [ + ['instruction', 'u8'], + ['resource', 'pubkey'], + ], + }, + ], + [ + PlaceBidArgs, + { + kind: 'struct', + fields: [ + ['instruction', 'u8'], + ['amount', 'u64'], + ['resource', 'pubkey'], + ], + }, + ], + [ + AuctionData, + { + kind: 'struct', + fields: [ + ['authority', 'pubkey'], + ['resource', 'pubkey'], + ['tokenMint', 'pubkey'], + ['lastBid', { kind: 'option', type: 'u64' }], + ['endedAt', { kind: 'option', type: 'u64' }], + ['endAuctionAt', { kind: 'option', type: 'u64' }], + ['auctionGap', { kind: 'option', type: 'u64' }], + ['state', 'u8'], + ['bidState', BidState], + ], + }, + ], + [ + BidState, + { + kind: 'struct', + fields: [ + ['type', 'u8'], + ['bids', [Bid]], + ['max', 'u64'], + ], + }, + ], + [ + Bid, + { + kind: 'struct', + fields: [ + ['key', 'pubkey'], + ['amount', 'u64'], + ], + }, + ], + [ + BidderMetadata, + { + kind: 'struct', + fields: [ + ['bidderPubkey', 'pubkey'], + ['auctionPubkey', 'pubkey'], + ['lastBid', 'u64'], + ['lastBidTimestamp', 'u64'], + ['cancelled', 'u8'], + ], + }, + ], + [ + BidderPot, + { + kind: 'struct', + fields: [ + ['bidderPot', 'pubkey'], + ['bidderAct', 'pubkey'], + ['auctionAct', 'pubkey'], + ], + }, + ], +]); + +export const decodeAuctionData = (buffer: Buffer) => { + return deserializeBorsh(AUCTION_SCHEMA, AuctionData, buffer) as AuctionData; +}; + +export async function createAuction( + winners: WinnerLimit, + resource: PublicKey, + endAuctionAt: BN | null, + auctionGap: BN | null, + tokenMint: PublicKey, + authority: PublicKey, + creator: PublicKey, + instructions: TransactionInstruction[], +) { + const auctionProgramId = programIds().auction; + + const data = Buffer.from( + serialize( + AUCTION_SCHEMA, + new CreateAuctionArgs({ + winners, + resource, + endAuctionAt, + auctionGap, + tokenMint, + authority, + }), + ), + ); + + const auctionKey: PublicKey = ( + await PublicKey.findProgramAddress( + [ + Buffer.from(AUCTION_PREFIX), + auctionProgramId.toBuffer(), + resource.toBuffer(), + ], + auctionProgramId, + ) + )[0]; + + const keys = [ + { + pubkey: creator, + isSigner: true, + isWritable: true, + }, + { + pubkey: auctionKey, + isSigner: false, + isWritable: true, + }, + { + pubkey: SYSVAR_RENT_PUBKEY, + isSigner: false, + isWritable: false, + }, + { + pubkey: SystemProgram.programId, + isSigner: false, + isWritable: false, + }, + ]; + instructions.push( + new TransactionInstruction({ + keys, + programId: auctionProgramId, + data: data, + }), + ); +} + +export async function startAuction( + resource: PublicKey, + creator: PublicKey, + instructions: TransactionInstruction[], +) { + const auctionProgramId = programIds().auction; + + const data = Buffer.from( + serialize( + AUCTION_SCHEMA, + new StartAuctionArgs({ + resource, + }), + ), + ); + + const auctionKey: PublicKey = ( + await PublicKey.findProgramAddress( + [ + Buffer.from(AUCTION_PREFIX), + auctionProgramId.toBuffer(), + resource.toBuffer(), + ], + auctionProgramId, + ) + )[0]; + + const keys = [ + { + pubkey: creator, + isSigner: false, + isWritable: true, + }, + { + pubkey: auctionKey, + isSigner: false, + isWritable: true, + }, + { + pubkey: SYSVAR_CLOCK_PUBKEY, + isSigner: false, + isWritable: false, + }, + ]; + instructions.push( + new TransactionInstruction({ + keys, + programId: auctionProgramId, + data: data, + }), + ); +} + +export async function placeBid( + bidderPubkey: PublicKey, + bidderPotTokenPubkey: PublicKey, + tokenMintPubkey: PublicKey, + transferAuthority: PublicKey, + payer: PublicKey, + resource: PublicKey, + amount: BN, + instructions: TransactionInstruction[], +) { + const auctionProgramId = programIds().auction; + + const data = Buffer.from( + serialize( + AUCTION_SCHEMA, + new PlaceBidArgs({ + resource, + amount, + }), + ), + ); + + const auctionKey: PublicKey = ( + await PublicKey.findProgramAddress( + [ + Buffer.from(AUCTION_PREFIX), + auctionProgramId.toBuffer(), + resource.toBuffer(), + ], + auctionProgramId, + ) + )[0]; + + const bidderPotKey: PublicKey = ( + await PublicKey.findProgramAddress( + [ + Buffer.from(AUCTION_PREFIX), + auctionProgramId.toBuffer(), + auctionKey.toBuffer(), + bidderPubkey.toBuffer(), + ], + auctionProgramId, + ) + )[0]; + const bidderMetaKey: PublicKey = ( + await PublicKey.findProgramAddress( + [ + Buffer.from(AUCTION_PREFIX), + auctionProgramId.toBuffer(), + auctionKey.toBuffer(), + bidderPubkey.toBuffer(), + Buffer.from('metadata'), + ], + auctionProgramId, + ) + )[0]; + + const keys = [ + { + pubkey: bidderPubkey, + isSigner: false, + isWritable: true, + }, + { + pubkey: bidderPotKey, + isSigner: false, + isWritable: true, + }, + { + pubkey: bidderPotTokenPubkey, + isSigner: false, + isWritable: true, + }, + { + pubkey: bidderMetaKey, + isSigner: false, + isWritable: true, + }, + { + pubkey: auctionKey, + isSigner: false, + isWritable: true, + }, + { + pubkey: tokenMintPubkey, + isSigner: false, + isWritable: true, + }, + { + pubkey: transferAuthority, + isSigner: true, + isWritable: false, + }, + { + pubkey: payer, + isSigner: true, + isWritable: false, + }, + { + pubkey: SYSVAR_CLOCK_PUBKEY, + isSigner: false, + isWritable: false, + }, + { + pubkey: SYSVAR_RENT_PUBKEY, + isSigner: false, + isWritable: false, + }, + { + pubkey: SystemProgram.programId, + isSigner: false, + isWritable: false, + }, + { + pubkey: programIds().token, + isSigner: false, + isWritable: false, + }, + ]; + instructions.push( + new TransactionInstruction({ + keys, + programId: auctionProgramId, + data: data, + }), + ); +} diff --git a/packages/common/src/actions/index.ts b/packages/common/src/actions/index.ts index 362a768..f11ceca 100644 --- a/packages/common/src/actions/index.ts +++ b/packages/common/src/actions/index.ts @@ -1 +1,4 @@ export * from './account'; +export * from './metadata'; +export * from './vault'; +export * from './auction'; diff --git a/packages/common/src/actions/metadata.ts b/packages/common/src/actions/metadata.ts new file mode 100644 index 0000000..ca86c3e --- /dev/null +++ b/packages/common/src/actions/metadata.ts @@ -0,0 +1,780 @@ +import { + PublicKey, + SystemProgram, + SYSVAR_RENT_PUBKEY, + TransactionInstruction, +} from '@solana/web3.js'; +import { programIds } from '../utils/ids'; +import { deserializeBorsh } from './../utils/borsh'; +import { serialize } from 'borsh'; +import BN from 'bn.js'; +import { PublicKeyInput } from 'node:crypto'; +import { ParsedAccount } from '..'; + +export const METADATA_PREFIX = 'metadata'; +export const EDITION = 'edition'; + +export const MAX_NAME_LENGTH = 32; + +export const MAX_SYMBOL_LENGTH = 10; + +export const MAX_URI_LENGTH = 200; + +export const MAX_METADATA_LEN = + 1 + 32 + MAX_NAME_LENGTH + MAX_SYMBOL_LENGTH + MAX_URI_LENGTH + 200; + +export const MAX_NAME_SYMBOL_LEN = 1 + 32 + 8; +export const MAX_MASTER_EDITION_KEN = 1 + 9 + 8 + 32; + +export enum MetadataKey { + MetadataV1 = 0, + NameSymbolTupleV1 = 1, + EditionV1 = 2, + MasterEditionV1 = 3, +} + +export enum MetadataCategory { + Audio = 'audio', + Video = 'video', + Image = 'image', +} + +export interface IMetadataExtension { + name: string; + symbol: string; + description: string; + // preview image + image: string; + // stores link to item on meta + externalUrl: string; + royalty: number; + files?: File[]; + category: MetadataCategory; +} + +export class MasterEdition { + key: MetadataKey; + supply: BN; + maxSupply?: BN; + /// Can be used to mint tokens that give one-time permission to mint a single limited edition. + masterMint: PublicKey; + + constructor(args: { + key: MetadataKey; + supply: BN; + maxSupply?: BN; + /// Can be used to mint tokens that give one-time permission to mint a single limited edition. + masterMint: PublicKey; + }) { + this.key = MetadataKey.MasterEditionV1; + this.supply = args.supply; + this.maxSupply = args.maxSupply; + this.masterMint = args.masterMint; + } +} + +export class Edition { + key: MetadataKey; + /// Points at MasterEdition struct + parent: PublicKey; + /// Starting at 0 for master record, this is incremented for each edition minted. + edition: BN; + + constructor(args: { key: MetadataKey; parent: PublicKey; edition: BN }) { + this.key = MetadataKey.EditionV1; + this.parent = args.parent; + this.edition = args.edition; + } +} +export class Metadata { + key: MetadataKey; + nonUniqueSpecificUpdateAuthority?: PublicKey; + + mint: PublicKey; + name: string; + symbol: string; + uri: string; + + extended?: IMetadataExtension; + masterEdition?: PublicKey; + edition?: PublicKey; + nameSymbolTuple?: PublicKey; + + constructor(args: { + nonUniqueSpecificUpdateAuthority?: PublicKey; + mint: PublicKey; + name: string; + symbol: string; + uri: string; + }) { + this.key = MetadataKey.MetadataV1; + this.nonUniqueSpecificUpdateAuthority = + args.nonUniqueSpecificUpdateAuthority; + this.mint = args.mint; + this.name = args.name; + this.symbol = args.symbol; + this.uri = args.uri; + } +} + +export class NameSymbolTuple { + key: MetadataKey; + updateAuthority: PublicKey; + metadata: PublicKey; + + constructor(args: { updateAuthority: Buffer; metadata: Buffer }) { + this.key = MetadataKey.NameSymbolTupleV1; + this.updateAuthority = new PublicKey(args.updateAuthority); + this.metadata = new PublicKey(args.metadata); + } +} + +class CreateMetadataArgs { + instruction: number = 0; + allowDuplicates: boolean = false; + name: string; + symbol: string; + uri: string; + + constructor(args: { + name: string; + symbol: string; + uri: string; + allowDuplicates?: boolean; + }) { + this.name = args.name; + this.symbol = args.symbol; + this.uri = args.uri; + this.allowDuplicates = !!args.allowDuplicates; + } +} +class UpdateMetadataArgs { + instruction: number = 1; + uri: string; + // Not used by this app, just required for instruction + nonUniqueSpecificUpdateAuthority: PublicKey | null; + + constructor(args: { + uri: string; + nonUniqueSpecificUpdateAuthority?: string; + }) { + this.uri = args.uri; + this.nonUniqueSpecificUpdateAuthority = args.nonUniqueSpecificUpdateAuthority + ? new PublicKey(args.nonUniqueSpecificUpdateAuthority) + : null; + } +} + +class TransferUpdateAuthorityArgs { + instruction: number = 2; + constructor() {} +} + +class CreateMasterEditionArgs { + instruction: number = 3; + maxSupply: BN | null; + constructor(args: { maxSupply: BN | null }) { + this.maxSupply = args.maxSupply; + } +} + +export const METADATA_SCHEMA = new Map([ + [ + CreateMetadataArgs, + { + kind: 'struct', + fields: [ + ['instruction', 'u8'], + ['allowDuplicates', 'u8'], + ['name', 'string'], + ['symbol', 'string'], + ['uri', 'string'], + ], + }, + ], + [ + UpdateMetadataArgs, + { + kind: 'struct', + fields: [ + ['instruction', 'u8'], + ['uri', 'string'], + [ + 'nonUniqueSpecificUpdateAuthority', + { kind: 'option', type: 'pubkey' }, + ], + ], + }, + ], + [ + TransferUpdateAuthorityArgs, + { + kind: 'struct', + fields: [['instruction', 'u8']], + }, + ], + [ + CreateMasterEditionArgs, + { + kind: 'struct', + fields: [ + ['instruction', 'u8'], + ['maxSupply', { kind: 'option', type: 'u64' }], + ], + }, + ], + [ + MasterEdition, + { + kind: 'struct', + fields: [ + ['key', 'u8'], + ['supply', 'u64'], + ['maxSupply', { kind: 'option', type: 'u64' }], + ['masterMint', 'pubkey'], + ], + }, + ], + [ + Edition, + { + kind: 'struct', + fields: [ + ['key', 'u8'], + ['parent', 'pubkey'], + ['edition', 'u64'], + ], + }, + ], + [ + Metadata, + { + kind: 'struct', + fields: [ + ['key', 'u8'], + [ + 'nonUniqueSpecificUpdateAuthority', + { kind: 'option', type: 'pubkey' }, + ], + ['mint', 'pubkey'], + ['name', 'string'], + ['symbol', 'string'], + ['uri', 'string'], + ], + }, + ], + [ + NameSymbolTuple, + { + kind: 'struct', + fields: [ + ['key', 'u8'], + ['updateAuthority', 'pubkey'], + ['metadata', 'pubkey'], + ], + }, + ], +]); + +export const decodeMetadata = async (buffer: Buffer): Promise => { + const metadata = deserializeBorsh( + METADATA_SCHEMA, + Metadata, + buffer, + ) as Metadata; + metadata.nameSymbolTuple = await getNameSymbol(metadata); + metadata.edition = await getEdition(metadata.mint); + metadata.masterEdition = await getEdition(metadata.mint); + return metadata; +}; + +export const decodeEdition = (buffer: Buffer) => { + return deserializeBorsh(METADATA_SCHEMA, Edition, buffer) as Edition; +}; + +export const decodeMasterEdition = (buffer: Buffer) => { + return deserializeBorsh( + METADATA_SCHEMA, + MasterEdition, + buffer, + ) as MasterEdition; +}; + +export const decodeNameSymbolTuple = (buffer: Buffer) => { + return deserializeBorsh( + METADATA_SCHEMA, + NameSymbolTuple, + buffer, + ) as NameSymbolTuple; +}; + +export async function transferUpdateAuthority( + account: PublicKey, + currentUpdateAuthority: PublicKey, + newUpdateAuthority: PublicKey, + instructions: TransactionInstruction[], +) { + const metadataProgramId = programIds().metadata; + + const data = Buffer.from( + serialize(METADATA_SCHEMA, new TransferUpdateAuthorityArgs()), + ); + + const keys = [ + { + pubkey: account, + isSigner: false, + isWritable: true, + }, + { + pubkey: currentUpdateAuthority, + isSigner: true, + isWritable: false, + }, + { + pubkey: newUpdateAuthority, + isSigner: false, + isWritable: false, + }, + ]; + instructions.push( + new TransactionInstruction({ + keys, + programId: metadataProgramId, + data: data, + }), + ); +} + +export async function updateMetadata( + symbol: string, + name: string, + uri: string, + newNonUniqueSpecificUpdateAuthority: string | undefined, + mintKey: PublicKey, + updateAuthority: PublicKey, + instructions: TransactionInstruction[], + metadataAccount?: PublicKey, + nameSymbolAccount?: PublicKey, +) { + const metadataProgramId = programIds().metadata; + + metadataAccount = + metadataAccount || + ( + await PublicKey.findProgramAddress( + [ + Buffer.from('metadata'), + metadataProgramId.toBuffer(), + mintKey.toBuffer(), + ], + metadataProgramId, + ) + )[0]; + + nameSymbolAccount = + nameSymbolAccount || + ( + await PublicKey.findProgramAddress( + [ + Buffer.from('metadata'), + metadataProgramId.toBuffer(), + Buffer.from(name), + Buffer.from(symbol), + ], + metadataProgramId, + ) + )[0]; + + const value = new UpdateMetadataArgs({ + uri, + nonUniqueSpecificUpdateAuthority: !newNonUniqueSpecificUpdateAuthority + ? undefined + : newNonUniqueSpecificUpdateAuthority, + }); + const data = Buffer.from(serialize(METADATA_SCHEMA, value)); + const keys = [ + { + pubkey: metadataAccount, + isSigner: false, + isWritable: true, + }, + { + pubkey: updateAuthority, + isSigner: true, + isWritable: false, + }, + { + pubkey: nameSymbolAccount, + isSigner: false, + isWritable: false, + }, + ]; + instructions.push( + new TransactionInstruction({ + keys, + programId: metadataProgramId, + data, + }), + ); + + return [metadataAccount, nameSymbolAccount]; +} + +export async function createMetadata( + symbol: string, + name: string, + uri: string, + allowDuplicates: boolean, + updateAuthority: PublicKey, + mintKey: PublicKey, + mintAuthorityKey: PublicKey, + instructions: TransactionInstruction[], + payer: PublicKey, +) { + const metadataProgramId = programIds().metadata; + + const metadataAccount = ( + await PublicKey.findProgramAddress( + [ + Buffer.from('metadata'), + metadataProgramId.toBuffer(), + mintKey.toBuffer(), + ], + metadataProgramId, + ) + )[0]; + + const nameSymbolAccount = ( + await PublicKey.findProgramAddress( + [ + Buffer.from('metadata'), + metadataProgramId.toBuffer(), + Buffer.from(name), + Buffer.from(symbol), + ], + metadataProgramId, + ) + )[0]; + + const value = new CreateMetadataArgs({ name, symbol, uri, allowDuplicates }); + const data = Buffer.from(serialize(METADATA_SCHEMA, value)); + + const keys = [ + { + pubkey: nameSymbolAccount, + isSigner: false, + isWritable: true, + }, + { + pubkey: metadataAccount, + isSigner: false, + isWritable: true, + }, + { + pubkey: mintKey, + isSigner: false, + isWritable: false, + }, + { + pubkey: mintAuthorityKey, + isSigner: true, + isWritable: false, + }, + { + pubkey: payer, + isSigner: true, + isWritable: false, + }, + { + pubkey: updateAuthority, + isSigner: false, + isWritable: false, + }, + { + pubkey: SystemProgram.programId, + isSigner: false, + isWritable: false, + }, + { + pubkey: SYSVAR_RENT_PUBKEY, + isSigner: false, + isWritable: false, + }, + ]; + instructions.push( + new TransactionInstruction({ + keys, + programId: metadataProgramId, + data, + }), + ); + + return [metadataAccount, nameSymbolAccount]; +} + +export async function createMasterEdition( + name: string, + symbol: string, + maxSupply: BN | undefined, + mintKey: PublicKey, + masterMintKey: PublicKey, + updateAuthorityKey: PublicKey, + mintAuthorityKey: PublicKey, + instructions: TransactionInstruction[], + payer: PublicKey, +) { + const metadataProgramId = programIds().metadata; + + const metadataAccount = ( + await PublicKey.findProgramAddress( + [ + Buffer.from(METADATA_PREFIX), + metadataProgramId.toBuffer(), + mintKey.toBuffer(), + ], + metadataProgramId, + ) + )[0]; + + const nameSymbolAccount = ( + await PublicKey.findProgramAddress( + [ + Buffer.from(METADATA_PREFIX), + metadataProgramId.toBuffer(), + Buffer.from(name), + Buffer.from(symbol), + ], + metadataProgramId, + ) + )[0]; + + const editionAccount = ( + await PublicKey.findProgramAddress( + [ + Buffer.from(METADATA_PREFIX), + metadataProgramId.toBuffer(), + mintKey.toBuffer(), + Buffer.from(EDITION), + ], + metadataProgramId, + ) + )[0]; + + const value = new CreateMasterEditionArgs({ maxSupply: maxSupply || null }); + const data = Buffer.from(serialize(METADATA_SCHEMA, value)); + + const keys = [ + { + pubkey: editionAccount, + isSigner: false, + isWritable: true, + }, + { + pubkey: mintKey, + isSigner: false, + isWritable: true, + }, + { + pubkey: masterMintKey, + isSigner: false, + isWritable: false, + }, + { + pubkey: updateAuthorityKey, + isSigner: true, + isWritable: false, + }, + { + pubkey: mintAuthorityKey, + isSigner: true, + isWritable: false, + }, + { + pubkey: metadataAccount, + isSigner: false, + isWritable: false, + }, + { + pubkey: nameSymbolAccount, + isSigner: false, + isWritable: false, + }, + { + pubkey: payer, + isSigner: true, + isWritable: false, + }, + { + pubkey: programIds().token, + isSigner: false, + isWritable: false, + }, + { + pubkey: SystemProgram.programId, + isSigner: false, + isWritable: false, + }, + { + pubkey: SYSVAR_RENT_PUBKEY, + isSigner: false, + isWritable: false, + }, + ]; + instructions.push( + new TransactionInstruction({ + keys, + programId: metadataProgramId, + data, + }), + ); +} + +export async function mintNewEditionFromMasterEditionViaToken( + newMint: PublicKey, + tokenMint: PublicKey, + newMintAuthority: PublicKey, + masterMint: PublicKey, + authorizationTokenHoldingAccount: PublicKey, + burnAuthority: PublicKey, + updateAuthorityOfMaster: PublicKey, + instructions: TransactionInstruction[], + payer: PublicKey, +) { + const metadataProgramId = programIds().metadata; + + const newMetadataKey = await getMetadata(newMint); + const masterMetadataKey = await getMetadata(tokenMint); + const newEdition = await getEdition(newMint); + const masterEdition = await getEdition(tokenMint); + + const data = Buffer.from([5]); + + const keys = [ + { + pubkey: newMetadataKey, + isSigner: false, + isWritable: true, + }, + { + pubkey: newEdition, + isSigner: false, + isWritable: true, + }, + { + pubkey: masterEdition, + isSigner: false, + isWritable: true, + }, + { + pubkey: newMint, + isSigner: false, + isWritable: true, + }, + { + pubkey: newMintAuthority, + isSigner: true, + isWritable: false, + }, + { + pubkey: masterMint, + isSigner: false, + isWritable: true, + }, + { + pubkey: authorizationTokenHoldingAccount, + isSigner: false, + isWritable: true, + }, + { + pubkey: burnAuthority, + isSigner: true, + isWritable: false, + }, + { + pubkey: payer, + isSigner: true, + isWritable: false, + }, + { + pubkey: updateAuthorityOfMaster, + isSigner: false, + isWritable: false, + }, + { + pubkey: masterMetadataKey, + isSigner: false, + isWritable: false, + }, + { + pubkey: programIds().token, + isSigner: false, + isWritable: false, + }, + { + pubkey: SystemProgram.programId, + isSigner: false, + isWritable: false, + }, + { + pubkey: SYSVAR_RENT_PUBKEY, + isSigner: false, + isWritable: false, + }, + ]; + instructions.push( + new TransactionInstruction({ + keys, + programId: metadataProgramId, + data, + }), + ); +} + +export async function getNameSymbol(metadata: Metadata): Promise { + const PROGRAM_IDS = programIds(); + + return ( + await PublicKey.findProgramAddress( + [ + Buffer.from(METADATA_PREFIX), + PROGRAM_IDS.metadata.toBuffer(), + metadata.mint.toBuffer(), + Buffer.from(metadata.name), + Buffer.from(metadata.symbol), + ], + PROGRAM_IDS.metadata, + ) + )[0]; +} + +export async function getEdition(tokenMint: PublicKey): Promise { + const PROGRAM_IDS = programIds(); + + return ( + await PublicKey.findProgramAddress( + [ + Buffer.from(METADATA_PREFIX), + PROGRAM_IDS.metadata.toBuffer(), + tokenMint.toBuffer(), + Buffer.from(EDITION), + ], + PROGRAM_IDS.metadata, + ) + )[0]; +} + +export async function getMetadata(tokenMint: PublicKey): Promise { + const PROGRAM_IDS = programIds(); + + return ( + await PublicKey.findProgramAddress( + [ + Buffer.from(METADATA_PREFIX), + PROGRAM_IDS.metadata.toBuffer(), + tokenMint.toBuffer(), + ], + PROGRAM_IDS.metadata, + ) + )[0]; +} diff --git a/packages/common/src/actions/vault.ts b/packages/common/src/actions/vault.ts new file mode 100644 index 0000000..ea993c8 --- /dev/null +++ b/packages/common/src/actions/vault.ts @@ -0,0 +1,695 @@ +import { + PublicKey, + SystemProgram, + SYSVAR_RENT_PUBKEY, + TransactionInstruction, +} from '@solana/web3.js'; +import { programIds } from '../utils/ids'; +import { deserializeBorsh } from './../utils/borsh'; +import { serialize } from 'borsh'; +import BN from 'bn.js'; + +export const VAULT_PREFIX = 'vault'; +export enum VaultKey { + VaultV1 = 0, + SafetyDepositBoxV1 = 1, + ExternalPriceAccountV1 = 2, +} + +export enum VaultState { + Inactive = 0, + Active = 1, + Combined = 2, + Deactivated = 3, +} + +export const MAX_VAULT_SIZE = + 1 + 32 + 32 + 32 + 32 + 1 + 32 + 1 + 32 + 1 + 1 + 8; + +export const MAX_EXTERNAL_ACCOUNT_SIZE = 1 + 8 + 32 + 1; +export class Vault { + key: VaultKey; + /// Store token program used + tokenProgram: PublicKey; + /// Mint that produces the fractional shares + fractionMint: PublicKey; + /// Authority who can make changes to the vault + authority: PublicKey; + /// treasury where fractional shares are held for redemption by authority + fractionTreasury: PublicKey; + /// treasury where monies are held for fractional share holders to redeem(burn) shares once buyout is made + redeemTreasury: PublicKey; + /// Can authority mint more shares from fraction_mint after activation + allowFurtherShareCreation: boolean; + + /// Must point at an ExternalPriceAccount, which gives permission and price for buyout. + pricingLookupAddress: PublicKey; + /// In inactive state, we use this to set the order key on Safety Deposit Boxes being added and + /// then we increment it and save so the next safety deposit box gets the next number. + /// In the Combined state during token redemption by authority, we use it as a decrementing counter each time + /// The authority of the vault withdrawals a Safety Deposit contents to count down how many + /// are left to be opened and closed down. Once this hits zero, and the fraction mint has zero shares, + /// then we can deactivate the vault. + tokenTypeCount: number; + state: VaultState; + + /// Once combination happens, we copy price per share to vault so that if something nefarious happens + /// to external price account, like price change, we still have the math 'saved' for use in our calcs + lockedPricePerShare: BN; + + constructor(args: { + tokenProgram: PublicKey; + fractionMint: PublicKey; + authority: PublicKey; + fractionTreasury: PublicKey; + redeemTreasury: PublicKey; + allowFurtherShareCreation: boolean; + pricingLookupAddress: PublicKey; + tokenTypeCount: number; + state: VaultState; + lockedPricePerShare: BN; + }) { + this.key = VaultKey.VaultV1; + this.tokenProgram = args.tokenProgram; + this.fractionMint = args.fractionMint; + this.authority = args.authority; + this.fractionTreasury = args.fractionTreasury; + this.redeemTreasury = args.redeemTreasury; + this.allowFurtherShareCreation = args.allowFurtherShareCreation; + this.pricingLookupAddress = args.pricingLookupAddress; + this.tokenTypeCount = args.tokenTypeCount; + this.state = args.state; + this.lockedPricePerShare = args.lockedPricePerShare; + } +} +export class SafetyDepositBox { + /// Each token type in a vault has it's own box that contains it's mint and a look-back + key: VaultKey; + /// VaultKey pointing to the parent vault + vault: PublicKey; + /// This particular token's mint + tokenMint: PublicKey; + /// Account that stores the tokens under management + store: PublicKey; + /// the order in the array of registries + order: number; + + constructor(args: { + vault: PublicKey; + tokenMint: PublicKey; + store: PublicKey; + order: number; + }) { + this.key = VaultKey.SafetyDepositBoxV1; + this.vault = args.vault; + this.tokenMint = args.tokenMint; + this.store = args.store; + this.order = args.order; + } +} + +export class ExternalPriceAccount { + key: VaultKey; + pricePerShare: BN; + /// Mint of the currency we are pricing the shares against, should be same as redeem_treasury. + /// Most likely will be USDC mint most of the time. + priceMint: PublicKey; + /// Whether or not combination has been allowed for this vault. + allowedToCombine: boolean; + + constructor(args: { + pricePerShare: BN; + priceMint: PublicKey; + allowedToCombine: boolean; + }) { + this.key = VaultKey.ExternalPriceAccountV1; + this.pricePerShare = args.pricePerShare; + this.priceMint = args.priceMint; + this.allowedToCombine = args.allowedToCombine; + } +} + +class InitVaultArgs { + instruction: number = 0; + allowFurtherShareCreation: boolean = false; + + constructor(args: { allowFurtherShareCreation: boolean }) { + this.allowFurtherShareCreation = args.allowFurtherShareCreation; + } +} + +class AmountArgs { + instruction: number; + amount: BN; + + constructor(args: { instruction: number; amount: BN }) { + this.instruction = args.instruction; + this.amount = args.amount; + } +} + +class NumberOfShareArgs { + instruction: number; + numberOfShares: BN; + + constructor(args: { instruction: number; numberOfShares: BN }) { + this.instruction = args.instruction; + this.numberOfShares = args.numberOfShares; + } +} + +class UpdateExternalPriceAccountArgs { + instruction: number = 9; + externalPriceAccount: ExternalPriceAccount; + + constructor(args: { externalPriceAccount: ExternalPriceAccount }) { + this.externalPriceAccount = args.externalPriceAccount; + } +} + +export const VAULT_SCHEMA = new Map([ + [ + InitVaultArgs, + { + kind: 'struct', + fields: [ + ['instruction', 'u8'], + ['allowFurtherShareCreation', 'u8'], + ], + }, + ], + [ + AmountArgs, + { + kind: 'struct', + fields: [ + ['instruction', 'u8'], + ['amount', 'u64'], + ], + }, + ], + [ + NumberOfShareArgs, + { + kind: 'struct', + fields: [ + ['instruction', 'u8'], + ['numberOfShares', 'u64'], + ], + }, + ], + [ + UpdateExternalPriceAccountArgs, + { + kind: 'struct', + fields: [ + ['instruction', 'u8'], + ['externalPriceAccount', ExternalPriceAccount], + ], + }, + ], + [ + Vault, + { + kind: 'struct', + fields: [ + ['key', 'u8'], + ['tokenProgram', 'pubkey'], + ['fractionMint', 'pubkey'], + ['authority', 'pubkey'], + ['fractionTreasury', 'pubkey'], + ['redeemTreasury', 'pubkey'], + ['allowFurtherShareCreation', 'u8'], + ['pricingLookupAddress', 'u8'], + ['tokenTypeCount', 'u8'], + ['state', 'u8'], + ['lockedPricePerShare', 'u64'], + ], + }, + ], + [ + SafetyDepositBox, + { + kind: 'struct', + fields: [ + ['key', 'u8'], + ['vault', 'pubkey'], + ['tokenMint', 'pubkey'], + ['store', 'pubkey'], + ['order', 'u8'], + ], + }, + ], + [ + ExternalPriceAccount, + { + kind: 'struct', + fields: [ + ['key', 'u8'], + ['pricePerShare', 'u64'], + ['priceMint', 'pubkey'], + ['allowedToCombine', 'u8'], + ], + }, + ], +]); + +export const decodeVault = (buffer: Buffer) => { + return deserializeBorsh(VAULT_SCHEMA, Vault, buffer) as Vault; +}; + +export const decodeSafetyDeposit = (buffer: Buffer) => { + return deserializeBorsh( + VAULT_SCHEMA, + SafetyDepositBox, + buffer, + ) as SafetyDepositBox; +}; + +export async function initVault( + allowFurtherShareCreation: boolean, + fractionalMint: PublicKey, + redeemTreasury: PublicKey, + fractionalTreasury: PublicKey, + vault: PublicKey, + vaultAuthority: PublicKey, + pricingLookupAddress: PublicKey, + instructions: TransactionInstruction[], +) { + const vaultProgramId = programIds().vault; + + const data = Buffer.from( + serialize(VAULT_SCHEMA, new InitVaultArgs({ allowFurtherShareCreation })), + ); + + const keys = [ + { + pubkey: fractionalMint, + isSigner: false, + isWritable: true, + }, + { + pubkey: redeemTreasury, + isSigner: false, + isWritable: true, + }, + { + pubkey: fractionalTreasury, + isSigner: false, + isWritable: true, + }, + { + pubkey: vault, + isSigner: false, + isWritable: true, + }, + { + pubkey: vaultAuthority, + isSigner: false, + isWritable: false, + }, + { + pubkey: pricingLookupAddress, + isSigner: false, + isWritable: false, + }, + { + pubkey: programIds().token, + isSigner: false, + isWritable: false, + }, + + { + pubkey: SYSVAR_RENT_PUBKEY, + isSigner: false, + isWritable: false, + }, + ]; + instructions.push( + new TransactionInstruction({ + keys, + programId: vaultProgramId, + data: data, + }), + ); +} + +export async function getSafetyDepositBox( + vault: PublicKey, + tokenMint: PublicKey, +): Promise { + const vaultProgramId = programIds().vault; + + return ( + await PublicKey.findProgramAddress( + [Buffer.from(VAULT_PREFIX), vault.toBuffer(), tokenMint.toBuffer()], + vaultProgramId, + ) + )[0]; +} + +export async function addTokenToInactiveVault( + amount: BN, + tokenMint: PublicKey, + tokenAccount: PublicKey, + tokenStoreAccount: PublicKey, + vault: PublicKey, + vaultAuthority: PublicKey, + payer: PublicKey, + transferAuthority: PublicKey, + instructions: TransactionInstruction[], +) { + const vaultProgramId = programIds().vault; + + const safetyDepositBox: PublicKey = await getSafetyDepositBox( + vault, + tokenMint, + ); + + const value = new AmountArgs({ + instruction: 1, + amount, + }); + + const data = Buffer.from(serialize(VAULT_SCHEMA, value)); + const keys = [ + { + pubkey: safetyDepositBox, + isSigner: false, + isWritable: true, + }, + { + pubkey: tokenAccount, + isSigner: false, + isWritable: true, + }, + { + pubkey: tokenStoreAccount, + isSigner: false, + isWritable: true, + }, + { + pubkey: vault, + isSigner: false, + isWritable: true, + }, + { + pubkey: vaultAuthority, + isSigner: true, + isWritable: false, + }, + { + pubkey: payer, + isSigner: true, + isWritable: false, + }, + { + pubkey: transferAuthority, + isSigner: true, + isWritable: false, + }, + { + pubkey: programIds().token, + isSigner: false, + isWritable: false, + }, + { + pubkey: SYSVAR_RENT_PUBKEY, + isSigner: false, + isWritable: false, + }, + { + pubkey: SystemProgram.programId, + isSigner: false, + isWritable: false, + }, + ]; + instructions.push( + new TransactionInstruction({ + keys, + programId: vaultProgramId, + data, + }), + ); +} + +export async function activateVault( + numberOfShares: BN, + vault: PublicKey, + fractionMint: PublicKey, + fractionTreasury: PublicKey, + vaultAuthority: PublicKey, + instructions: TransactionInstruction[], +) { + const vaultProgramId = programIds().vault; + + const fractionMintAuthority = ( + await PublicKey.findProgramAddress( + [Buffer.from(VAULT_PREFIX), vaultProgramId.toBuffer()], + vaultProgramId, + ) + )[0]; + + const value = new NumberOfShareArgs({ instruction: 2, numberOfShares }); + const data = Buffer.from(serialize(VAULT_SCHEMA, value)); + + const keys = [ + { + pubkey: vault, + isSigner: false, + isWritable: true, + }, + { + pubkey: fractionMint, + isSigner: false, + isWritable: true, + }, + { + pubkey: fractionTreasury, + isSigner: false, + isWritable: true, + }, + { + pubkey: fractionMintAuthority, + isSigner: false, + isWritable: false, + }, + { + pubkey: vaultAuthority, + isSigner: true, + isWritable: false, + }, + { + pubkey: programIds().token, + isSigner: false, + isWritable: false, + }, + ]; + instructions.push( + new TransactionInstruction({ + keys, + programId: vaultProgramId, + data, + }), + ); +} + +export async function combineVault( + vault: PublicKey, + outstandingShareTokenAccount: PublicKey, + payingTokenAccount: PublicKey, + fractionMint: PublicKey, + fractionTreasury: PublicKey, + redeemTreasury: PublicKey, + newVaultAuthority: PublicKey | undefined, + vaultAuthority: PublicKey, + transferAuthority: PublicKey, + externalPriceAccount: PublicKey, + instructions: TransactionInstruction[], +) { + const vaultProgramId = programIds().vault; + + const burnAuthority = ( + await PublicKey.findProgramAddress( + [Buffer.from(VAULT_PREFIX), vaultProgramId.toBuffer()], + vaultProgramId, + ) + )[0]; + + const data = Buffer.from([3]); + + const keys = [ + { + pubkey: vault, + isSigner: false, + isWritable: true, + }, + { + pubkey: outstandingShareTokenAccount, + isSigner: false, + isWritable: true, + }, + { + pubkey: payingTokenAccount, + isSigner: false, + isWritable: true, + }, + { + pubkey: fractionMint, + isSigner: false, + isWritable: true, + }, + { + pubkey: fractionTreasury, + isSigner: false, + isWritable: true, + }, + { + pubkey: redeemTreasury, + isSigner: false, + isWritable: true, + }, + { + pubkey: newVaultAuthority || vaultAuthority, + isSigner: false, + isWritable: false, + }, + { + pubkey: vaultAuthority, + isSigner: true, + isWritable: false, + }, + { + pubkey: transferAuthority, + isSigner: true, + isWritable: false, + }, + { + pubkey: burnAuthority, + isSigner: false, + isWritable: false, + }, + { + pubkey: externalPriceAccount, + isSigner: false, + isWritable: false, + }, + { + pubkey: programIds().token, + isSigner: false, + isWritable: false, + }, + ]; + instructions.push( + new TransactionInstruction({ + keys, + programId: vaultProgramId, + data, + }), + ); +} + +export async function withdrawTokenFromSafetyDepositBox( + amount: BN, + destination: PublicKey, + safetyDepositBox: PublicKey, + storeKey: PublicKey, + vault: PublicKey, + fractionMint: PublicKey, + vaultAuthority: PublicKey, + instructions: TransactionInstruction[], +) { + const vaultProgramId = programIds().vault; + + const transferAuthority = ( + await PublicKey.findProgramAddress( + [Buffer.from(VAULT_PREFIX), vaultProgramId.toBuffer()], + vaultProgramId, + ) + )[0]; + + const value = new AmountArgs({ instruction: 5, amount }); + const data = Buffer.from(serialize(VAULT_SCHEMA, value)); + + const keys = [ + { + pubkey: destination, + isSigner: false, + isWritable: true, + }, + { + pubkey: safetyDepositBox, + isSigner: false, + isWritable: true, + }, + { + pubkey: storeKey, + isSigner: false, + isWritable: true, + }, + { + pubkey: vault, + isSigner: false, + isWritable: true, + }, + { + pubkey: fractionMint, + isSigner: false, + isWritable: true, + }, + { + pubkey: vaultAuthority, + isSigner: true, + isWritable: false, + }, + { + pubkey: transferAuthority, + isSigner: false, + isWritable: false, + }, + { + pubkey: programIds().token, + isSigner: false, + isWritable: false, + }, + { + pubkey: SYSVAR_RENT_PUBKEY, + isSigner: false, + isWritable: false, + }, + ]; + instructions.push( + new TransactionInstruction({ + keys, + programId: vaultProgramId, + data, + }), + ); +} + +export async function updateExternalPriceAccount( + externalPriceAccountKey: PublicKey, + externalPriceAccount: ExternalPriceAccount, + instructions: TransactionInstruction[], +) { + const vaultProgramId = programIds().vault; + + const value = new UpdateExternalPriceAccountArgs({ externalPriceAccount }); + const data = Buffer.from(serialize(VAULT_SCHEMA, value)); + console.log('Data', data); + + const keys = [ + { + pubkey: externalPriceAccountKey, + isSigner: false, + isWritable: true, + }, + ]; + instructions.push( + new TransactionInstruction({ + keys, + programId: vaultProgramId, + data, + }), + ); +} diff --git a/packages/common/src/components/AppBar/index.tsx b/packages/common/src/components/AppBar/index.tsx index 91096c2..cd4a072 100644 --- a/packages/common/src/components/AppBar/index.tsx +++ b/packages/common/src/components/AppBar/index.tsx @@ -1,7 +1,6 @@ import React from 'react'; import { Button, Popover } from 'antd'; import { CurrentUserBadge } from '../CurrentUserBadge'; -import { CurrentUserWalletBadge } from '../CurrentUserWalletBadge'; import { SettingOutlined } from '@ant-design/icons'; import { Settings } from '../Settings'; import { LABELS } from '../../constants/labels'; @@ -20,11 +19,7 @@ export const AppBar = (props: {
{props.left} {connected ? ( - props.useWalletBadge ? ( - - ) : ( - - ) + ) : ( { +export interface ConnectButtonProps + extends ButtonProps, + React.RefAttributes { allowWalletChange?: boolean; } -export const ConnectButton = ( - props: ConnectButtonProps -) => { +export const ConnectButton = (props: ConnectButtonProps) => { const { connected, connect, select, provider } = useWallet(); const { onClick, children, disabled, allowWalletChange, ...rest } = props; @@ -17,25 +17,30 @@ export const ConnectButton = ( const menu = ( - Change Wallet + + Change Wallet + ); - if(!provider || !allowWalletChange) { - return ; + if (!provider || !allowWalletChange) { + return ( + + ); } return ( + onClick={connected ? onClick : connect} + disabled={connected && disabled} + overlay={menu} + > Connect ); diff --git a/packages/common/src/components/CurrentUserBadge/index.tsx b/packages/common/src/components/CurrentUserBadge/index.tsx index 41c9617..df1e269 100644 --- a/packages/common/src/components/CurrentUserBadge/index.tsx +++ b/packages/common/src/components/CurrentUserBadge/index.tsx @@ -5,8 +5,15 @@ import { LAMPORTS_PER_SOL } from '@solana/web3.js'; import { useWallet } from '../../contexts/wallet'; import { useNativeAccount } from '../../contexts/accounts'; import { formatNumber, shortenAddress } from '../../utils'; +import './styles.css'; +import { Popover } from 'antd'; +import { Settings } from '../Settings'; -export const CurrentUserBadge = (props: {}) => { +export const CurrentUserBadge = (props: { + showBalance?: boolean; + showAddress?: boolean; + iconSize?: number; +}) => { const { wallet } = useWallet(); const { account } = useNativeAccount(); @@ -14,20 +21,62 @@ export const CurrentUserBadge = (props: {}) => { return null; } - // should use SOL â—Ž ? + const iconStyle: React.CSSProperties = props.showAddress + ? { + marginLeft: '0.5rem', + display: 'flex', + width: props.iconSize, + borderRadius: 50, + } + : { + display: 'flex', + width: props.iconSize, + paddingLeft: 0, + borderRadius: 50, + }; + + const baseWalletKey: React.CSSProperties = { + height: props.iconSize, + cursor: 'pointer', + userSelect: 'none', + }; + const walletKeyStyle: React.CSSProperties = props.showAddress + ? baseWalletKey + : { ...baseWalletKey, paddingLeft: 0 }; + + let name = props.showAddress ? shortenAddress(`${wallet.publicKey}`) : ''; + const unknownWallet = wallet as any; + if (unknownWallet.name) { + name = unknownWallet.name; + } + + let image = ( + + ); + + if (unknownWallet.image) { + image = ; + } return (
- - {formatNumber.format((account?.lamports || 0) / LAMPORTS_PER_SOL)} SOL - -
- {shortenAddress(`${wallet.publicKey}`)} - -
+ {props.showBalance && ( + + {formatNumber.format((account?.lamports || 0) / LAMPORTS_PER_SOL)} SOL + + )} + + } + trigger="click" + > +
+ {name && {name}} + {image} +
+
); }; diff --git a/packages/common/src/components/CurrentUserBadge/styles.less b/packages/common/src/components/CurrentUserBadge/styles.less new file mode 100644 index 0000000..5940a94 --- /dev/null +++ b/packages/common/src/components/CurrentUserBadge/styles.less @@ -0,0 +1,15 @@ +.wallet-wrapper { + padding-left: 0.7rem; + border-radius: 0.5rem; + display: flex; + align-items: center; + white-space: nowrap; +} + +.wallet-key { + padding: 0.1rem 0.5rem 0.1rem 0.7rem; + margin-left: 0.3rem; + border-radius: 0.5rem; + display: flex; + align-items: center; +} diff --git a/packages/common/src/components/CurrentUserWalletBadge/index.tsx b/packages/common/src/components/CurrentUserWalletBadge/index.tsx deleted file mode 100644 index 970adb8..0000000 --- a/packages/common/src/components/CurrentUserWalletBadge/index.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import React from 'react'; - -import { useWallet, WALLET_PROVIDERS } from '../../contexts/wallet'; -import { shortenAddress } from '../../utils'; - -export const CurrentUserWalletBadge = (props: { - showDisconnect?: boolean; -}) => { - const { wallet, disconnect } = useWallet(); - - if (!wallet || !wallet.publicKey) { - return null; - } - - return ( -
-
- {"icon"} p.name === "Sollet")[0]?.icon} - style={{ marginRight: 8 }} - /> - {shortenAddress(`${wallet.publicKey}`)} - {props.showDisconnect && disconnect()}>X} -
-
- ); -}; diff --git a/packages/common/src/components/EtherscanLink/index.tsx b/packages/common/src/components/EtherscanLink/index.tsx index 321febb..745daf3 100644 --- a/packages/common/src/components/EtherscanLink/index.tsx +++ b/packages/common/src/components/EtherscanLink/index.tsx @@ -3,7 +3,7 @@ import { Typography } from 'antd'; import { shortenAddress } from '../../utils/utils'; export const EtherscanLink = (props: { - address: string ; + address: string; type: string; code?: boolean; style?: React.CSSProperties; diff --git a/packages/common/src/components/Icons/info.tsx b/packages/common/src/components/Icons/info.tsx index 4bb0e3a..6ef9758 100644 --- a/packages/common/src/components/Icons/info.tsx +++ b/packages/common/src/components/Icons/info.tsx @@ -1,7 +1,7 @@ -import { Button, Popover } from "antd"; -import React from "react"; +import { Button, Popover } from 'antd'; +import React from 'react'; -import { InfoCircleOutlined } from "@ant-design/icons"; +import { InfoCircleOutlined } from '@ant-design/icons'; export const Info = (props: { text: React.ReactElement; diff --git a/packages/common/src/components/Identicon/index.tsx b/packages/common/src/components/Identicon/index.tsx index 1e108c9..55d824c 100644 --- a/packages/common/src/components/Identicon/index.tsx +++ b/packages/common/src/components/Identicon/index.tsx @@ -20,18 +20,16 @@ export const Identicon = (props: { useEffect(() => { if (address && ref.current) { try { - - ref.current.innerHTML = ''; - ref.current.className = className || ''; - ref.current.appendChild( - Jazzicon( - style?.width || 16, - parseInt(bs58.decode(address).toString('hex').slice(5, 15), 16), - ), - ); - - }catch (err) { - // TODO + ref.current.innerHTML = ''; + ref.current.className = className || ''; + ref.current.appendChild( + Jazzicon( + style?.width || 16, + parseInt(bs58.decode(address).toString('hex').slice(5, 15), 16), + ), + ); + } catch (err) { + // TODO } } }, [address, style, className]); diff --git a/packages/common/src/components/Input/numeric.tsx b/packages/common/src/components/Input/numeric.tsx index c307e3e..84ebc77 100644 --- a/packages/common/src/components/Input/numeric.tsx +++ b/packages/common/src/components/Input/numeric.tsx @@ -1,11 +1,11 @@ -import React from "react"; -import { Input } from "antd"; +import React from 'react'; +import { Input } from 'antd'; export class NumericInput extends React.Component { onChange = (e: any) => { const { value } = e.target; const reg = /^-?\d*(\.\d*)?$/; - if (reg.test(value) || value === "" || value === "-") { + if (reg.test(value) || value === '' || value === '-') { this.props.onChange(value); } }; @@ -17,14 +17,14 @@ export class NumericInput extends React.Component { if (value === undefined || value === null) return; if ( value.charAt && - (value.charAt(value.length - 1) === "." || value === "-") + (value.charAt(value.length - 1) === '.' || value === '-') ) { valueTemp = value.slice(0, -1); } - if (value.startsWith && (value.startsWith(".") || value.startsWith("-."))) { - valueTemp = valueTemp.replace(".", "0."); + if (value.startsWith && (value.startsWith('.') || value.startsWith('-.'))) { + valueTemp = valueTemp.replace('.', '0.'); } - if (valueTemp.replace) onChange?.(valueTemp.replace(/0*(\d+)/, "$1")); + if (valueTemp.replace) onChange?.(valueTemp.replace(/0*(\d+)/, '$1')); if (onBlur) { onBlur(); } diff --git a/packages/common/src/components/Settings/index.tsx b/packages/common/src/components/Settings/index.tsx index 76d70c0..0ca0c74 100644 --- a/packages/common/src/components/Settings/index.tsx +++ b/packages/common/src/components/Settings/index.tsx @@ -2,13 +2,15 @@ import React from 'react'; import { Button, Select } from 'antd'; import { useWallet } from '../../contexts/wallet'; import { ENDPOINTS, useConnectionConfig } from '../../contexts/connection'; +import { shortenAddress } from '../../utils'; +import { CopyOutlined } from '@ant-design/icons'; export const Settings = ({ additionalSettings, }: { additionalSettings?: JSX.Element; }) => { - const { connected, disconnect } = useWallet(); + const { connected, disconnect, select, wallet } = useWallet(); const { endpoint, setEndpoint } = useConnectionConfig(); return ( @@ -27,9 +29,33 @@ export const Settings = ({ ))} {connected && ( - + <> + Wallet: + {wallet?.publicKey && ( + + )} + + + + )} {additionalSettings}
diff --git a/packages/common/src/components/TokenIcon/index.tsx b/packages/common/src/components/TokenIcon/index.tsx index 21da7ec..c70a793 100644 --- a/packages/common/src/components/TokenIcon/index.tsx +++ b/packages/common/src/components/TokenIcon/index.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { PublicKey } from '@solana/web3.js'; -import {getTokenIcon, KnownTokenMap} from '../../utils'; +import { getTokenIcon, KnownTokenMap } from '../../utils'; import { useConnectionConfig } from '../../contexts/connection'; import { Identicon } from '../Identicon'; @@ -9,7 +9,7 @@ export const TokenIcon = (props: { style?: React.CSSProperties; size?: number; className?: string; - tokenMap?: KnownTokenMap, + tokenMap?: KnownTokenMap; }) => { let icon: string | undefined = ''; if (props.tokenMap) { diff --git a/packages/common/src/components/index.tsx b/packages/common/src/components/index.tsx index ef34e9c..78c3fb9 100644 --- a/packages/common/src/components/index.tsx +++ b/packages/common/src/components/index.tsx @@ -1,7 +1,6 @@ export { ExplorerLink } from './ExplorerLink/index'; export { ConnectButton } from './ConnectButton/index'; export { CurrentUserBadge } from './CurrentUserBadge/index'; -export { CurrentUserWalletBadge } from './CurrentUserWalletBadge/index'; export { Identicon } from './Identicon/index'; export { Info } from './Icons/info'; export { NumericInput } from './Input/numeric'; diff --git a/packages/common/src/constants/math.ts b/packages/common/src/constants/math.ts index d0b4865..6e06293 100644 --- a/packages/common/src/constants/math.ts +++ b/packages/common/src/constants/math.ts @@ -1,4 +1,4 @@ -import BN from "bn.js"; +import BN from 'bn.js'; export const TEN = new BN(10); export const HALF_WAD = TEN.pow(new BN(18)); diff --git a/packages/common/src/contexts/accounts.tsx b/packages/common/src/contexts/accounts.tsx index 1334cfe..f481358 100644 --- a/packages/common/src/contexts/accounts.tsx +++ b/packages/common/src/contexts/accounts.tsx @@ -328,22 +328,30 @@ const UseNativeAccount = () => { ); useEffect(() => { - if (!connection || !wallet?.publicKey) { - return; - } + let subId = 0; + const updateAccount = (account: AccountInfo | null) => { + if (account) { + updateCache(account); + setNativeAccount(account); + } + }; - connection.getAccountInfo(wallet.publicKey).then(acc => { - if (acc) { - updateCache(acc); - setNativeAccount(acc); + (async () => { + if (!connection || !wallet?.publicKey) { + return; } - }); - connection.onAccountChange(wallet.publicKey, acc => { - if (acc) { - updateCache(acc); - setNativeAccount(acc); + + const account = await connection.getAccountInfo(wallet.publicKey); + updateAccount(account); + + subId = connection.onAccountChange(wallet.publicKey, updateAccount); + })(); + + return () => { + if (subId) { + connection.removeAccountChangeListener(subId); } - }); + }; }, [setNativeAccount, wallet, wallet?.publicKey, connection, updateCache]); return { nativeAccount }; @@ -361,7 +369,7 @@ const precacheUserTokenAccounts = async ( // used for filtering account updates over websocket PRECACHED_OWNERS.add(owner.toBase58()); - // user accounts are update via ws subscription + // user accounts are updated via ws subscription const accounts = await connection.getTokenAccountsByOwner(owner, { programId: programIds().token, }); diff --git a/packages/common/src/contexts/connection.tsx b/packages/common/src/contexts/connection.tsx index 6313acc..6bbddad 100644 --- a/packages/common/src/contexts/connection.tsx +++ b/packages/common/src/contexts/connection.tsx @@ -1,10 +1,16 @@ -import { useLocalStorageState } from '../utils/utils'; +import { sleep, useLocalStorageState } from '../utils/utils'; import { Account, + BlockhashAndFeeCalculator, clusterApiUrl, + Commitment, Connection, + RpcResponseAndContext, + SignatureStatus, + SimulatedTransactionResponse, Transaction, TransactionInstruction, + TransactionSignature, } from '@solana/web3.js'; import React, { useContext, useEffect, useMemo, useState } from 'react'; import { notify } from '../utils/notifications'; @@ -17,7 +23,9 @@ import { } from '@solana/spl-token-registry'; export type ENV = + | 'mainnet-beta (Serum)' | 'mainnet-beta' + | 'mainnet-beta (Serum)' | 'testnet' | 'devnet' | 'localnet' @@ -25,10 +33,15 @@ export type ENV = export const ENDPOINTS = [ { - name: 'mainnet-beta' as ENV, + name: 'mainnet-beta (Serum)' as ENV, endpoint: 'https://solana-api.projectserum.com/', ChainId: ChainId.MainnetBeta, }, + { + name: 'mainnet-beta' as ENV, + endpoint: 'https://api.mainnet-beta.solana.com', + ChainId: ChainId.MainnetBeta, + }, { name: 'testnet' as ENV, endpoint: clusterApiUrl('testnet'), @@ -236,77 +249,90 @@ export const getErrorForTransaction = async ( return errors; }; +export enum SequenceType { + Sequential, + Parallel, + StopOnFailure, +} + export const sendTransactions = async ( connection: Connection, wallet: any, instructionSet: TransactionInstruction[][], signersSet: Account[][], - awaitConfirmation = true, - commitment = 'singleGossip', + sequenceType: SequenceType = SequenceType.Parallel, + commitment: Commitment = 'singleGossip', successCallback: (txid: string, ind: number) => void = (txid, ind) => {}, - failCallback: (txid: string, ind: number) => boolean = (txid, ind) => false, -) => { + failCallback: (reason: string, ind: number) => boolean = (txid, ind) => false, + block?: BlockhashAndFeeCalculator, +): Promise => { const unsignedTxns: Transaction[] = []; + + if (!block) { + block = await connection.getRecentBlockhash(commitment); + } + for (let i = 0; i < instructionSet.length; i++) { const instructions = instructionSet[i]; const signers = signersSet[i]; + + if (instructions.length === 0) { + continue; + } + let transaction = new Transaction(); instructions.forEach(instruction => transaction.add(instruction)); - transaction.recentBlockhash = ( - await connection.getRecentBlockhash('max') - ).blockhash; + transaction.recentBlockhash = block.blockhash; transaction.setSigners( - // fee payied by the wallet owner + // fee payed by the wallet owner wallet.publicKey, ...signers.map(s => s.publicKey), ); + if (signers.length > 0) { transaction.partialSign(...signers); } + unsignedTxns.push(transaction); } + const signedTxns = await wallet.signAllTransactions(unsignedTxns); - const rawTransactions = signedTxns.map((t: Transaction) => t.serialize()); - let options = { - skipPreflight: true, - commitment, - }; - for (let i = 0; i < rawTransactions.length; i++) { - const rawTransaction = rawTransactions[i]; - const txid = await connection.sendRawTransaction(rawTransaction, options); + const pendingTxns: Promise<{ txid: string; slot: number }>[] = []; - if (awaitConfirmation) { - const status = ( - await connection.confirmTransaction( - txid, - options && (options.commitment as any), - ) - ).value; + let breakEarlyObject = { breakEarly: false }; + for (let i = 0; i < signedTxns.length; i++) { + const signedTxnPromise = sendSignedTransaction({ + connection, + signedTransaction: signedTxns[i], + }); - if (status?.err && !failCallback(txid, i)) { - const errors = await getErrorForTransaction(connection, txid); - notify({ - message: 'Transaction failed...', - description: ( - <> - {errors.map(err => ( -
{err}
- ))} - - - ), - type: 'error', - }); - - throw new Error( - `Raw transaction ${txid} failed (${JSON.stringify(status)})`, - ); - } else { + signedTxnPromise + .then(({ txid, slot }) => { successCallback(txid, i); + }) + .catch(reason => { + failCallback(signedTxns[i], i); + if (sequenceType == SequenceType.StopOnFailure) { + breakEarlyObject.breakEarly = true; + } + }); + + if (sequenceType != SequenceType.Parallel) { + await signedTxnPromise; + if (breakEarlyObject.breakEarly) { + return i; // REturn the txn we failed on by index } + } else { + pendingTxns.push(signedTxnPromise); } } + + if (sequenceType != SequenceType.Parallel) { + await Promise.all(pendingTxns); + } + + return signedTxns.length; }; export const sendTransaction = async ( @@ -315,22 +341,33 @@ export const sendTransaction = async ( instructions: TransactionInstruction[], signers: Account[], awaitConfirmation = true, - commitment = 'singleGossip', + commitment: Commitment = 'singleGossip', + includesFeePayer: boolean = false, + block?: BlockhashAndFeeCalculator, ) => { let transaction = new Transaction(); instructions.forEach(instruction => transaction.add(instruction)); transaction.recentBlockhash = ( - await connection.getRecentBlockhash('max') + block || (await connection.getRecentBlockhash(commitment)) ).blockhash; - transaction.setSigners( - // fee payied by the wallet owner - wallet.publicKey, - ...signers.map(s => s.publicKey), - ); + + if (includesFeePayer) { + transaction.setSigners(...signers.map(s => s.publicKey)); + } else { + transaction.setSigners( + // fee payed by the wallet owner + wallet.publicKey, + ...signers.map(s => s.publicKey), + ); + } + if (signers.length > 0) { transaction.partialSign(...signers); } - transaction = await wallet.signTransaction(transaction); + if (!includesFeePayer) { + transaction = await wallet.signTransaction(transaction); + } + const rawTransaction = transaction.serialize(); let options = { skipPreflight: true, @@ -341,14 +378,16 @@ export const sendTransaction = async ( let slot = 0; if (awaitConfirmation) { - const confirmation = await connection.confirmTransaction( + const confirmation = await awaitTransactionSignatureConfirmation( txid, - options && (options.commitment as any), + DEFAULT_TIMEOUT, + connection, + commitment, ); - const status = confirmation.value; - slot = confirmation.context.slot; - if (status?.err) { + slot = confirmation?.slot || 0; + + if (confirmation?.err) { const errors = await getErrorForTransaction(connection, txid); notify({ message: 'Transaction failed...', @@ -371,3 +410,254 @@ export const sendTransaction = async ( return { txid, slot }; }; + +export const sendTransactionWithRetry = async ( + connection: Connection, + wallet: any, + instructions: TransactionInstruction[], + signers: Account[], + commitment: Commitment = 'singleGossip', + includesFeePayer: boolean = false, + block?: BlockhashAndFeeCalculator, + beforeSend?: () => void, +) => { + let transaction = new Transaction(); + instructions.forEach(instruction => transaction.add(instruction)); + transaction.recentBlockhash = ( + block || (await connection.getRecentBlockhash(commitment)) + ).blockhash; + + if (includesFeePayer) { + transaction.setSigners(...signers.map(s => s.publicKey)); + } else { + transaction.setSigners( + // fee payed by the wallet owner + wallet.publicKey, + ...signers.map(s => s.publicKey), + ); + } + + if (signers.length > 0) { + transaction.partialSign(...signers); + } + if (!includesFeePayer) { + transaction = await wallet.signTransaction(transaction); + } + + if (beforeSend) { + beforeSend(); + } + + const { txid, slot } = await sendSignedTransaction({ + connection, + signedTransaction: transaction, + }); + + return { txid, slot }; +}; + +export const getUnixTs = () => { + return new Date().getTime() / 1000; +}; + +const DEFAULT_TIMEOUT = 15000; + +export async function sendSignedTransaction({ + signedTransaction, + connection, + timeout = DEFAULT_TIMEOUT, +}: { + signedTransaction: Transaction; + connection: Connection; + sendingMessage?: string; + sentMessage?: string; + successMessage?: string; + timeout?: number; +}): Promise<{ txid: string; slot: number }> { + const rawTransaction = signedTransaction.serialize(); + const startTime = getUnixTs(); + let slot = 0; + const txid: TransactionSignature = await connection.sendRawTransaction( + rawTransaction, + { + skipPreflight: true, + }, + ); + + console.log('Started awaiting confirmation for', txid); + + let done = false; + (async () => { + while (!done && getUnixTs() - startTime < timeout) { + connection.sendRawTransaction(rawTransaction, { + skipPreflight: true, + }); + await sleep(500); + } + })(); + try { + const confirmation = await awaitTransactionSignatureConfirmation( + txid, + timeout, + connection, + 'recent', + true, + ); + + if (confirmation.err) { + console.error(confirmation.err); + throw new Error('Transaction failed: Custom instruction error'); + } + + slot = confirmation?.slot || 0; + } catch (err) { + if (err.timeout) { + throw new Error('Timed out awaiting confirmation on transaction'); + } + let simulateResult: SimulatedTransactionResponse | null = null; + try { + simulateResult = ( + await simulateTransaction(connection, signedTransaction, 'single') + ).value; + } catch (e) {} + if (simulateResult && simulateResult.err) { + if (simulateResult.logs) { + for (let i = simulateResult.logs.length - 1; i >= 0; --i) { + const line = simulateResult.logs[i]; + if (line.startsWith('Program log: ')) { + throw new Error( + 'Transaction failed: ' + line.slice('Program log: '.length), + ); + } + } + } + throw new Error(JSON.stringify(simulateResult.err)); + } + // throw new Error('Transaction failed'); + } finally { + done = true; + } + + console.log('Latency', txid, getUnixTs() - startTime); + return { txid, slot }; +} + +async function simulateTransaction( + connection: Connection, + transaction: Transaction, + commitment: Commitment, +): Promise> { + // @ts-ignore + transaction.recentBlockhash = await connection._recentBlockhash( + // @ts-ignore + connection._disableBlockhashCaching, + ); + + const signData = transaction.serializeMessage(); + // @ts-ignore + const wireTransaction = transaction._serialize(signData); + const encodedTransaction = wireTransaction.toString('base64'); + const config: any = { encoding: 'base64', commitment }; + const args = [encodedTransaction, config]; + + // @ts-ignore + const res = await connection._rpcRequest('simulateTransaction', args); + if (res.error) { + throw new Error('failed to simulate transaction: ' + res.error.message); + } + return res.result; +} + +async function awaitTransactionSignatureConfirmation( + txid: TransactionSignature, + timeout: number, + connection: Connection, + commitment: Commitment = 'recent', + queryStatus = false, +) { + let done = false; + let status: SignatureStatus | null = { + slot: 0, + confirmations: 0, + err: null, + }; + let subId = 0; + await new Promise((resolve, reject) => { + (async () => { + setTimeout(() => { + if (done) { + return; + } + done = true; + reject({ timeout: true }); + }, timeout); + try { + subId = connection.onSignature( + txid, + (result, context) => { + done = true; + status = { + err: result.err, + slot: context.slot, + confirmations: 0, + }; + if (result.err) { + console.log('Rejected via websocket', result.err); + reject(result.err); + } else { + console.log('Resolved via websocket', result); + resolve(result); + } + }, + commitment, + ); + } catch (e) { + done = true; + console.error('WS error in setup', txid, e); + } + while (!done && queryStatus) { + // eslint-disable-next-line no-loop-func + (async () => { + try { + const signatureStatuses = await connection.getSignatureStatuses([ + txid, + ]); + status = signatureStatuses && signatureStatuses.value[0]; + if (!done) { + if (!status) { + console.log('REST null result for', txid, status); + } else if (status.err) { + console.log('REST error for', txid, status); + done = true; + reject(status.err); + } else if (!status.confirmations) { + console.log('REST no confirmations for', txid, status); + } else { + console.log('REST confirmation for', txid, status); + done = true; + resolve(status); + } + } + } catch (e) { + if (!done) { + console.log('REST connection error: txid', txid, e); + } + } + })(); + await sleep(2000); + } + })(); + }) + .catch(err => { + //@ts-ignore + if (connection._signatureSubscriptions[subId]) + connection.removeSignatureListener(subId); + }) + .then(_ => { + //@ts-ignore + if (connection._signatureSubscriptions[subId]) + connection.removeSignatureListener(subId); + }); + done = true; + return status; +} diff --git a/packages/common/src/contexts/wallet.tsx b/packages/common/src/contexts/wallet.tsx index 8e68fa7..8061e00 100644 --- a/packages/common/src/contexts/wallet.tsx +++ b/packages/common/src/contexts/wallet.tsx @@ -1,117 +1,166 @@ -import { WalletAdapter } from "@solana/wallet-base"; +import { WalletAdapter } from '@solana/wallet-base'; -import Wallet from "@project-serum/sol-wallet-adapter"; -import { Button, Modal } from "antd"; -import React, { useCallback, useContext, useEffect, useMemo, useState} from "react"; -import { notify } from "../utils/notifications"; -import { useConnectionConfig } from "./connection"; -import { useLocalStorageState } from "../utils/utils"; -import { LedgerProvider } from "@solana/wallet-ledger"; -import { SolongWalletAdapter } from "../wallet-adapters/solong"; -import { PhantomWalletAdapter } from "../wallet-adapters/phantom"; +import Wallet from '@project-serum/sol-wallet-adapter'; +import { Button, Modal } from 'antd'; +import React, { + useCallback, + useContext, + useEffect, + useMemo, + useState, +} from 'react'; +import { notify } from './../utils/notifications'; +import { useConnectionConfig } from './connection'; +import { useLocalStorageState } from '../utils/utils'; +import { SolongWalletAdapter } from '../wallet-adapters/solong'; +import { PhantomWalletAdapter } from '../wallet-adapters/phantom'; +import { TorusWalletAdapter } from '../wallet-adapters/torus'; +import { useLocation } from 'react-router'; +import { LedgerWalletAdapter } from '@solana/wallet-ledger'; +import {MathWalletAdapter} from "../wallet-adapters/mathWallet"; -const ASSETS_URL = 'https://raw.githubusercontent.com/solana-labs/oyster/main/assets/wallets/'; +const ASSETS_URL = + 'https://raw.githubusercontent.com/solana-labs/oyster/main/assets/wallets/'; export const WALLET_PROVIDERS = [ { - name: "Sollet", - url: "https://www.sollet.io", - icon: `${ASSETS_URL}sollet.svg`, - }, { - name: "Solong", - url: "https://solongwallet.com", - icon: `${ASSETS_URL}solong.png`, - adapter: SolongWalletAdapter, - }, { - name: "Solflare", - url: "https://solflare.com/access-wallet", - icon: `${ASSETS_URL}solflare.svg`, - }, { - name: "MathWallet", - url: "https://mathwallet.org", - icon: `${ASSETS_URL}mathwallet.svg`, - }, - LedgerProvider, - { - name: "Phantom", - url: "https://www.phantom.app", + name: 'Phantom', + url: 'https://www.phantom.app', icon: `https://www.phantom.app/img/logo.png`, adapter: PhantomWalletAdapter, }, + { + name: 'Ledger', + url: 'https://www.ledger.com', + icon: `${ASSETS_URL}ledger.svg`, + adapter: LedgerWalletAdapter, + }, + { + name: 'Sollet', + url: 'https://www.sollet.io', + icon: `${ASSETS_URL}sollet.svg`, + }, + { + name: 'Solong', + url: 'https://solongwallet.com', + icon: `${ASSETS_URL}solong.png`, + adapter: SolongWalletAdapter, + }, + // TODO: enable when fully functional + { + name: 'MathWallet', + url: 'https://mathwallet.org', + icon: `${ASSETS_URL}mathwallet.svg`, + adapter: MathWalletAdapter, + }, + // { + // name: 'Torus', + // url: 'https://tor.us', + // icon: `${ASSETS_URL}torus.svg`, + // adapter: TorusWalletAdapter, + // } + + // Solflare doesnt allow external connections for all apps + // { + // name: "Solflare", + // url: "https://solflare.com/access-wallet", + // icon: `${ASSETS_URL}solflare.svg`, + // }, ]; const WalletContext = React.createContext<{ - wallet: WalletAdapter | undefined, - connected: boolean, - select: () => void, - provider: typeof WALLET_PROVIDERS[number] | undefined, + wallet: WalletAdapter | undefined; + connected: boolean; + select: () => void; + provider: typeof WALLET_PROVIDERS[number] | undefined; }>({ wallet: undefined, connected: false, - select () {}, + select() {}, provider: undefined, }); export function WalletProvider({ children = null as any }) { const { endpoint } = useConnectionConfig(); + const location = useLocation(); + const [autoConnect, setAutoConnect] = useState( + location.pathname.indexOf('result=') >= 0 || false, + ); + const [providerUrl, setProviderUrl] = useLocalStorageState('walletProvider'); - const [autoConnect, setAutoConnect] = useState(false); - const [providerUrl, setProviderUrl] = useLocalStorageState("walletProvider"); + const provider = useMemo( + () => WALLET_PROVIDERS.find(({ url }) => url === providerUrl), + [providerUrl], + ); - const provider = useMemo(() => WALLET_PROVIDERS.find(({ url }) => url === providerUrl), [providerUrl]); - - const wallet = useMemo(function() { - if (provider) { - return new (provider.adapter || Wallet)(providerUrl, endpoint) as WalletAdapter; - } - }, [provider, providerUrl, endpoint]); + const wallet = useMemo( + function () { + if (provider) { + try { + return new (provider.adapter || Wallet)( + providerUrl, + endpoint, + ) as WalletAdapter; + } catch (e) { + console.log(`Error connecting to wallet ${provider.name}: ${e}`); + return undefined; + } + } + }, + [provider, providerUrl, endpoint], + ); const [connected, setConnected] = useState(false); useEffect(() => { if (wallet) { - wallet.on("connect", () => { + wallet.on('connect', () => { if (wallet.publicKey) { setConnected(true); const walletPublicKey = wallet.publicKey.toBase58(); const keyToDisplay = - walletPublicKey.length > 20 - ? `${walletPublicKey.substring(0, 7)}.....${walletPublicKey.substring( + walletPublicKey.length > 20 + ? `${walletPublicKey.substring( + 0, + 7, + )}.....${walletPublicKey.substring( walletPublicKey.length - 7, - walletPublicKey.length - )}` - : walletPublicKey; + walletPublicKey.length, + )}` + : walletPublicKey; notify({ - message: "Wallet update", - description: "Connected to wallet " + keyToDisplay, + message: 'Wallet update', + description: 'Connected to wallet ' + keyToDisplay, }); } }); - wallet.on("disconnect", () => { + wallet.on('disconnect', () => { setConnected(false); + // setProviderUrl(null) notify({ - message: "Wallet update", - description: "Disconnected from wallet", + message: 'Wallet update', + description: 'Disconnected from wallet', }); }); } return () => { setConnected(false); - if(wallet) { + // setProviderUrl(null) + if (wallet) { wallet.disconnect(); } }; }, [wallet]); useEffect(() => { - if(wallet && autoConnect) { + if (wallet && autoConnect) { wallet.connect(); setAutoConnect(false); } - return () => {} + return () => {}; }, [wallet, autoConnect]); const [isModalVisible, setIsModalVisible] = useState(false); @@ -133,36 +182,42 @@ export function WalletProvider({ children = null as any }) { title="Select Wallet" okText="Connect" visible={isModalVisible} - okButtonProps={{ style: { display: "none" } }} + okButtonProps={{ style: { display: 'none' } }} onCancel={close} - width={ 400 }> - {WALLET_PROVIDERS.map((provider) => { + width={400} + > + {WALLET_PROVIDERS.map((provider, idx) => { const onClick = function () { setProviderUrl(provider.url); setAutoConnect(true); close(); - } + }; return ( - - ) + + ); })} @@ -176,11 +231,11 @@ export const useWallet = () => { connected, provider, select, - connect () { + connect() { wallet ? wallet.connect() : select(); }, - disconnect () { + disconnect() { wallet?.disconnect(); }, }; -} +}; diff --git a/packages/common/src/hooks/useAccountByMint.ts b/packages/common/src/hooks/useAccountByMint.ts index e0ae165..0271d94 100644 --- a/packages/common/src/hooks/useAccountByMint.ts +++ b/packages/common/src/hooks/useAccountByMint.ts @@ -5,7 +5,9 @@ export const useAccountByMint = (mint?: string | PublicKey) => { const { userAccounts } = useUserAccounts(); const mintAddress = typeof mint === 'string' ? mint : mint?.toBase58(); - const index = userAccounts.findIndex((acc) => acc.info.mint.toBase58() === mintAddress); + const index = userAccounts.findIndex( + acc => acc.info.mint.toBase58() === mintAddress, + ); if (index !== -1) { return userAccounts[index]; diff --git a/packages/common/src/hooks/useTokenName.ts b/packages/common/src/hooks/useTokenName.ts index 2bcdcc5..b4a6b60 100644 --- a/packages/common/src/hooks/useTokenName.ts +++ b/packages/common/src/hooks/useTokenName.ts @@ -4,6 +4,7 @@ import { getTokenName } from '../utils/utils'; export function useTokenName(mintAddress?: string | PublicKey) { const { tokenMap } = useConnectionConfig(); - const address = typeof mintAddress === 'string' ? mintAddress : mintAddress?.toBase58(); + const address = + typeof mintAddress === 'string' ? mintAddress : mintAddress?.toBase58(); return getTokenName(tokenMap, address); } diff --git a/packages/common/src/models/account.ts b/packages/common/src/models/account.ts index 6570c81..df0473c 100644 --- a/packages/common/src/models/account.ts +++ b/packages/common/src/models/account.ts @@ -65,27 +65,17 @@ export function approve( const transferAuthority = existingTransferAuthority || new Account(); const delegateKey = delegate ?? transferAuthority.publicKey; - const instruction = Token.createApproveInstruction( - tokenProgram, - account, - delegateKey, - owner, - [], - amount, + instructions.push( + Token.createApproveInstruction( + tokenProgram, + account, + delegate ?? transferAuthority.publicKey, + owner, + [], + amount, + ), ); - // Temp. workaround for a bug in Token.createApproveInstruction which doesn't add the delegate account to signers - instruction.keys = instruction.keys.map(k => - k.pubkey.equals(delegateKey) - ? { - ...k, - isSigner: true, - } - : k, - ); - - instructions.push(instruction); - if (autoRevoke) { cleanupInstructions.push( Token.createRevokeInstruction(tokenProgram, account, owner, []), diff --git a/packages/common/src/models/tokenSwap.ts b/packages/common/src/models/tokenSwap.ts index e095ddd..a5017ab 100644 --- a/packages/common/src/models/tokenSwap.ts +++ b/packages/common/src/models/tokenSwap.ts @@ -14,7 +14,7 @@ const FEE_LAYOUT = BufferLayout.struct( BufferLayout.nu64('hostFeeNumerator'), BufferLayout.nu64('hostFeeDenominator'), ], - 'fees' + 'fees', ); export const TokenSwapLayoutLegacyV0 = BufferLayout.struct([ @@ -27,42 +27,58 @@ export const TokenSwapLayoutLegacyV0 = BufferLayout.struct([ uint64('feesDenominator'), ]); -export const TokenSwapLayoutV1: typeof BufferLayout.Structure = BufferLayout.struct([ - BufferLayout.u8('isInitialized'), - BufferLayout.u8('nonce'), - publicKey('tokenProgramId'), - publicKey('tokenAccountA'), - publicKey('tokenAccountB'), - publicKey('tokenPool'), - publicKey('mintA'), - publicKey('mintB'), - publicKey('feeAccount'), - BufferLayout.u8('curveType'), - uint64('tradeFeeNumerator'), - uint64('tradeFeeDenominator'), - uint64('ownerTradeFeeNumerator'), - uint64('ownerTradeFeeDenominator'), - uint64('ownerWithdrawFeeNumerator'), - uint64('ownerWithdrawFeeDenominator'), - BufferLayout.blob(16, 'padding'), -]); +export const TokenSwapLayoutV1: typeof BufferLayout.Structure = BufferLayout.struct( + [ + BufferLayout.u8('isInitialized'), + BufferLayout.u8('nonce'), + publicKey('tokenProgramId'), + publicKey('tokenAccountA'), + publicKey('tokenAccountB'), + publicKey('tokenPool'), + publicKey('mintA'), + publicKey('mintB'), + publicKey('feeAccount'), + BufferLayout.u8('curveType'), + uint64('tradeFeeNumerator'), + uint64('tradeFeeDenominator'), + uint64('ownerTradeFeeNumerator'), + uint64('ownerTradeFeeDenominator'), + uint64('ownerWithdrawFeeNumerator'), + uint64('ownerWithdrawFeeDenominator'), + BufferLayout.blob(16, 'padding'), + ], +); -const CURVE_NODE = BufferLayout.union(BufferLayout.u8(), BufferLayout.blob(32), 'curve'); +const CURVE_NODE = BufferLayout.union( + BufferLayout.u8(), + BufferLayout.blob(32), + 'curve', +); CURVE_NODE.addVariant(0, BufferLayout.struct([]), 'constantProduct'); -CURVE_NODE.addVariant(1, BufferLayout.struct([BufferLayout.nu64('token_b_price')]), 'constantPrice'); +CURVE_NODE.addVariant( + 1, + BufferLayout.struct([BufferLayout.nu64('token_b_price')]), + 'constantPrice', +); CURVE_NODE.addVariant(2, BufferLayout.struct([]), 'stable'); -CURVE_NODE.addVariant(3, BufferLayout.struct([BufferLayout.nu64('token_b_offset')]), 'offset'); +CURVE_NODE.addVariant( + 3, + BufferLayout.struct([BufferLayout.nu64('token_b_offset')]), + 'offset', +); -export const TokenSwapLayout: typeof BufferLayout.Structure = BufferLayout.struct([ - BufferLayout.u8('isInitialized'), - BufferLayout.u8('nonce'), - publicKey('tokenProgramId'), - publicKey('tokenAccountA'), - publicKey('tokenAccountB'), - publicKey('tokenPool'), - publicKey('mintA'), - publicKey('mintB'), - publicKey('feeAccount'), - FEE_LAYOUT, - CURVE_NODE, -]); +export const TokenSwapLayout: typeof BufferLayout.Structure = BufferLayout.struct( + [ + BufferLayout.u8('isInitialized'), + BufferLayout.u8('nonce'), + publicKey('tokenProgramId'), + publicKey('tokenAccountA'), + publicKey('tokenAccountB'), + publicKey('tokenPool'), + publicKey('mintA'), + publicKey('mintB'), + publicKey('feeAccount'), + FEE_LAYOUT, + CURVE_NODE, + ], +); diff --git a/packages/common/src/types/buffer-layout.d.ts b/packages/common/src/types/buffer-layout.d.ts index ded59a5..32e44d0 100644 --- a/packages/common/src/types/buffer-layout.d.ts +++ b/packages/common/src/types/buffer-layout.d.ts @@ -1,9 +1,9 @@ -declare module "buffer-layout" { +declare module 'buffer-layout' { const bl: any; export = bl; } -declare module "jazzicon" { +declare module 'jazzicon' { const jazzicon: any; export = jazzicon; } diff --git a/packages/common/src/types/sol-wallet-adapter.d.ts b/packages/common/src/types/sol-wallet-adapter.d.ts index 6464233..41acf5d 100644 --- a/packages/common/src/types/sol-wallet-adapter.d.ts +++ b/packages/common/src/types/sol-wallet-adapter.d.ts @@ -1,4 +1,4 @@ -declare module "@project-serum/sol-wallet-adapter" { +declare module '@project-serum/sol-wallet-adapter' { const adapter: any; export = adapter; } diff --git a/packages/common/src/utils/borsh.ts b/packages/common/src/utils/borsh.ts new file mode 100644 index 0000000..7b72b12 --- /dev/null +++ b/packages/common/src/utils/borsh.ts @@ -0,0 +1,110 @@ +import { PublicKey } from '@solana/web3.js'; +import { + serialize, + BinaryReader, + Schema, + BorshError, + BinaryWriter, +} from 'borsh'; + +(BinaryReader.prototype as any).readPubkey = function () { + const reader = (this as unknown) as BinaryReader; + const array = reader.readFixedArray(32); + return new PublicKey(array); +}; + +(BinaryWriter.prototype as any).writePubkey = function (value: PublicKey) { + const writer = (this as unknown) as BinaryWriter; + writer.writeFixedArray(value.toBuffer()); +}; + +function capitalizeFirstLetter(string: string): string { + return string.charAt(0).toUpperCase() + string.slice(1); +} + +function deserializeField( + schema: Schema, + fieldName: string, + fieldType: any, + reader: BinaryReader, +): any { + try { + if (typeof fieldType === 'string') { + return (reader as any)[`read${capitalizeFirstLetter(fieldType)}`](); + } + + if (fieldType instanceof Array) { + if (typeof fieldType[0] === 'number') { + return reader.readFixedArray(fieldType[0]); + } + + return reader.readArray(() => + deserializeField(schema, fieldName, fieldType[0], reader), + ); + } + + if (fieldType.kind === 'option') { + const option = reader.readU8(); + if (option) { + return deserializeField(schema, fieldName, fieldType.type, reader); + } + + return undefined; + } + + return deserializeStruct(schema, fieldType, reader); + } catch (error) { + if (error instanceof BorshError) { + error.addToFieldPath(fieldName); + } + throw error; + } +} + +function deserializeStruct( + schema: Schema, + classType: any, + reader: BinaryReader, +) { + const structSchema = schema.get(classType); + if (!structSchema) { + throw new BorshError(`Class ${classType.name} is missing in schema`); + } + + if (structSchema.kind === 'struct') { + const result: any = {}; + for (const [fieldName, fieldType] of schema.get(classType).fields) { + result[fieldName] = deserializeField( + schema, + fieldName, + fieldType, + reader, + ); + } + return new classType(result); + } + + if (structSchema.kind === 'enum') { + const idx = reader.readU8(); + if (idx >= structSchema.values.length) { + throw new BorshError(`Enum index: ${idx} is out of range`); + } + const [fieldName, fieldType] = structSchema.values[idx]; + const fieldValue = deserializeField(schema, fieldName, fieldType, reader); + return new classType({ [fieldName]: fieldValue }); + } + + throw new BorshError( + `Unexpected schema kind: ${structSchema.kind} for ${classType.constructor.name}`, + ); +} + +/// Deserializes object from bytes using schema. +export function deserializeBorsh( + schema: Schema, + classType: any, + buffer: Buffer, +): any { + const reader = new BinaryReader(buffer); + return deserializeStruct(schema, classType, reader); +} diff --git a/packages/common/src/utils/eventEmitter.ts b/packages/common/src/utils/eventEmitter.ts index 1111bee..ee31a71 100644 --- a/packages/common/src/utils/eventEmitter.ts +++ b/packages/common/src/utils/eventEmitter.ts @@ -1,7 +1,7 @@ -import { EventEmitter as Emitter } from "eventemitter3"; +import { EventEmitter as Emitter } from 'eventemitter3'; export class CacheUpdateEvent { - static type = "CacheUpdate"; + static type = 'CacheUpdate'; id: string; parser: any; isNew: boolean; @@ -13,7 +13,7 @@ export class CacheUpdateEvent { } export class CacheDeleteEvent { - static type = "CacheUpdate"; + static type = 'CacheUpdate'; id: string; constructor(id: string) { this.id = id; @@ -21,7 +21,7 @@ export class CacheDeleteEvent { } export class MarketUpdateEvent { - static type = "MarketUpdate"; + static type = 'MarketUpdate'; ids: Set; constructor(ids: Set) { this.ids = ids; @@ -50,7 +50,7 @@ export class EventEmitter { raiseCacheUpdated(id: string, isNew: boolean, parser: any) { this.emitter.emit( CacheUpdateEvent.type, - new CacheUpdateEvent(id, isNew, parser) + new CacheUpdateEvent(id, isNew, parser), ); } diff --git a/packages/common/src/utils/ids.ts b/packages/common/src/utils/ids.ts index f4ee9b9..db142ab 100644 --- a/packages/common/src/utils/ids.ts +++ b/packages/common/src/utils/ids.ts @@ -18,6 +18,25 @@ export let SPL_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID = new PublicKey( export let BPF_UPGRADE_LOADER_ID = new PublicKey( 'BPFLoaderUpgradeab1e11111111111111111111111', ); +export let METADATA_PROGRAM_ID = new PublicKey( + 'metaTA73sFPqA8whreUbBsbn3SLJH2vhrW9fP5dmfdC', +); + +export const MEMO_ID = new PublicKey( + 'MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr', +); + +export const VAULT_ID = new PublicKey( + '94wRaYAQdC2gYF76AUTYSugNJ3rAC4EimjAMPwM7uYry', +); + +export const AUCTION_ID = new PublicKey( + 'C9nHkL6BfGx9M9MyYrJqAD5hPsGJd1fHpp1uAJA6vTCn', +); + +export const METAPLEX_ID = new PublicKey( + 'EPtpKdKW8qciGVd1UFyGjgbBHTbSAyvbY61h9uQGVgeu', +); export let SYSTEM = new PublicKey('11111111111111111111111111111111'); @@ -27,7 +46,7 @@ let WORMHOLE_BRIDGE: { wrappedMaster: string; }; -let TIMELOCK: { +let GOVERNANCE: { programId: PublicKey; }; @@ -47,7 +66,7 @@ export const ENABLE_FEES_INPUT = false; export const PROGRAM_IDS = [ { name: 'mainnet-beta', - timelock: () => ({ + governance: () => ({ programId: new PublicKey('9iAeqqppjn7g1Jn8o2cQCqU5aQVV3h4q9bbWdKRbeC2w'), }), wormhole: () => ({ @@ -68,8 +87,8 @@ export const PROGRAM_IDS = [ }, { name: 'testnet', - timelock: () => ({ - programId: new PublicKey('DCVPuhaGNMLh73FRWFroH4o3ERUhBKMRWfBgJV94VqRk'), + governance: () => ({ + programId: new PublicKey('A9KW1nhwZUr1kMX8C6rgzZvAE9AwEEUi2C77SiVvEiuN'), }), wormhole: () => ({ pubkey: new PublicKey('5gQf5AUhAgWYgUCt9ouShm9H7dzzXUsLdssYwe5krKhg'), @@ -84,10 +103,11 @@ export const PROGRAM_IDS = [ legacy: [], }), }, + { name: 'devnet', - timelock: () => ({ - programId: new PublicKey('DCVPuhaGNMLh73FRWFroH4o3ERUhBKMRWfBgJV94VqRk'), + governance: () => ({ + programId: new PublicKey('C3FdFYAwoAanUUHrtxnnzN8A6R13RmRoDRWmLbcpZATp'), }), wormhole: () => ({ pubkey: new PublicKey('WormT3McKhFJ2RkiGpdw9GKvNCrB2aB54gb2uV9MfQC'), @@ -104,8 +124,8 @@ export const PROGRAM_IDS = [ }, { name: 'localnet', - timelock: () => ({ - programId: new PublicKey('3KEiR9eX7isb8xeFzTzbLZij8tKH6YFYUbMyjBp8ygDK'), + governance: () => ({ + programId: new PublicKey('2uWrXQ3tMurqTLe3Dmue6DzasUGV9UPqK7AK7HzS7v3D'), }), wormhole: () => ({ pubkey: new PublicKey('WormT3McKhFJ2RkiGpdw9GKvNCrB2aB54gb2uV9MfQC'), @@ -123,7 +143,7 @@ export const PROGRAM_IDS = [ ]; export const setProgramIds = (envName: string) => { - let instance = PROGRAM_IDS.find(env => env.name === envName); + let instance = PROGRAM_IDS.find(env => envName.indexOf(env.name) >= 0); if (!instance) { return; } @@ -136,7 +156,7 @@ export const setProgramIds = (envName: string) => { SWAP_PROGRAM_LAYOUT = swap.current.layout; SWAP_PROGRAM_LEGACY_IDS = swap.legacy; - TIMELOCK = instance.timelock(); + GOVERNANCE = instance.governance(); if (envName === 'mainnet-beta') { LENDING_PROGRAM_ID = new PublicKey( @@ -153,9 +173,14 @@ export const programIds = () => { swapLayout: SWAP_PROGRAM_LAYOUT, lending: LENDING_PROGRAM_ID, wormhole: WORMHOLE_BRIDGE, - timelock: TIMELOCK, + governance: GOVERNANCE, associatedToken: SPL_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID, bpf_upgrade_loader: BPF_UPGRADE_LOADER_ID, system: SYSTEM, + metadata: METADATA_PROGRAM_ID, + memo: MEMO_ID, + vault: VAULT_ID, + auction: AUCTION_ID, + metaplex: METAPLEX_ID, }; }; diff --git a/packages/common/src/utils/index.tsx b/packages/common/src/utils/index.tsx index ffb0edf..dbe5b1e 100644 --- a/packages/common/src/utils/index.tsx +++ b/packages/common/src/utils/index.tsx @@ -5,3 +5,4 @@ export * from './notifications'; export * from './utils'; export * from './strings'; export * as shortvec from './shortvec'; +export * from './borsh'; diff --git a/packages/common/src/utils/layout.ts b/packages/common/src/utils/layout.ts index 7fd555f..38931a4 100644 --- a/packages/common/src/utils/layout.ts +++ b/packages/common/src/utils/layout.ts @@ -37,9 +37,9 @@ export const uint64 = (property = 'uint64'): unknown => { return new BN( [...data] .reverse() - .map((i) => `00${i.toString(16)}`.slice(-2)) + .map(i => `00${i.toString(16)}`.slice(-2)) .join(''), - 16 + 16, ); }; @@ -69,9 +69,9 @@ export const uint128 = (property = 'uint128'): unknown => { return new BN( [...data] .reverse() - .map((i) => `00${i.toString(16)}`.slice(-2)) + .map(i => `00${i.toString(16)}`.slice(-2)) .join(''), - 16 + 16, ); }; @@ -100,7 +100,7 @@ export const rustString = (property = 'string'): unknown => { BufferLayout.u32('lengthPadding'), BufferLayout.blob(BufferLayout.offset(BufferLayout.u32(), -8), 'chars'), ], - property + property, ); const _decode = rsl.decode.bind(rsl); const _encode = rsl.encode.bind(rsl); diff --git a/packages/common/src/utils/notifications.tsx b/packages/common/src/utils/notifications.tsx index ae1dc15..a6d2ad8 100644 --- a/packages/common/src/utils/notifications.tsx +++ b/packages/common/src/utils/notifications.tsx @@ -1,13 +1,13 @@ -import React from "react"; -import { notification } from "antd"; +import React from 'react'; +import { notification } from 'antd'; // import Link from '../components/Link'; export function notify({ - message = "", + message = '', description = undefined as any, - txid = "", - type = "info", - placement = "bottomLeft", + txid = '', + type = 'info', + placement = 'bottomLeft', }) { if (txid) { // ; } (notification as any)[type]({ - message: {message}, + message: {message}, description: ( - {description} + {description} ), placement, style: { - backgroundColor: "white", + backgroundColor: 'white', }, }); } diff --git a/packages/common/src/wallet-adapters/mathWallet/index.tsx b/packages/common/src/wallet-adapters/mathWallet/index.tsx new file mode 100644 index 0000000..ffe246e --- /dev/null +++ b/packages/common/src/wallet-adapters/mathWallet/index.tsx @@ -0,0 +1,92 @@ +import EventEmitter from 'eventemitter3'; +import { PublicKey, Transaction } from '@solana/web3.js'; +import { WalletAdapter } from '@solana/wallet-base'; +import { notify } from '../../utils/notifications'; + +export class MathWalletAdapter extends EventEmitter implements WalletAdapter { + _publicKey: PublicKey | null; + _onProcess: boolean; + _connected: boolean; + constructor() { + super(); + this._publicKey = null; + this._onProcess = false; + this._connected = false; + this.connect = this.connect.bind(this); + } + + get publicKey() { + return this._publicKey; + } + + get connected() { + return this._connected; + } + + get autoApprove() { + return false; + } + + // eslint-disable-next-line + async signAllTransactions( + transactions: Transaction[], + ): Promise { + if (!this._provider) { + return transactions; + } + + return this._provider.signAllTransactions(transactions); + } + + private get _provider() { + if ((window as any)?.solana?.isMathWallet) { + return (window as any).solana; + } + return undefined; + } + + signTransaction(transaction: Transaction) { + if (!this._provider) { + return transaction; + } + + return this._provider.signTransaction(transaction); + } + + connect() { + if (this._onProcess) { + return; + } + if (!this._provider) { + notify({ + message: 'MathWallet Error', + description: + 'Please install and initialize Math wallet extension from Chrome first', + }); + return; + } + + this._onProcess = true; + this._provider + .getAccount() + .then((account: any) => { + this._publicKey = new PublicKey(account); + this._connected = true; + this.emit('connect', this._publicKey); + }) + .catch(() => { + this.disconnect(); + }) + .finally(() => { + this._onProcess = false; + }); + } + + disconnect() { + if (this._publicKey) { + this._publicKey = null; + this._connected = false; + this.emit('disconnect'); + } + } +} diff --git a/packages/common/src/wallet-adapters/phantom/index.tsx b/packages/common/src/wallet-adapters/phantom/index.tsx index 2d677ea..6618192 100644 --- a/packages/common/src/wallet-adapters/phantom/index.tsx +++ b/packages/common/src/wallet-adapters/phantom/index.tsx @@ -1,14 +1,14 @@ -import EventEmitter from "eventemitter3"; -import { PublicKey, Transaction } from "@solana/web3.js"; -import { notify } from "../../utils/notifications"; -import { WalletAdapter } from "@solana/wallet-base"; +import EventEmitter from 'eventemitter3'; +import { PublicKey, Transaction } from '@solana/web3.js'; +import { notify } from '../../utils/notifications'; +import { WalletAdapter } from '@solana/wallet-base'; -type PhantomEvent = "disconnect" | "connect"; +type PhantomEvent = 'disconnect' | 'connect'; type PhantomRequestMethod = - | "connect" - | "disconnect" - | "signTransaction" - | "signAllTransactions"; + | 'connect' + | 'disconnect' + | 'signTransaction' + | 'signAllTransactions'; interface PhantomProvider { publicKey?: PublicKey; @@ -26,6 +26,7 @@ export class PhantomWalletAdapter extends EventEmitter implements WalletAdapter { _provider: PhantomProvider | undefined; + _cachedCorrectKey?: PublicKey; constructor() { super(); this.connect = this.connect.bind(this); @@ -40,7 +41,7 @@ export class PhantomWalletAdapter } async signAllTransactions( - transactions: Transaction[] + transactions: Transaction[], ): Promise { if (!this._provider) { return transactions; @@ -50,7 +51,13 @@ export class PhantomWalletAdapter } get publicKey() { - return this._provider?.publicKey || null; + // Due to weird phantom bug where their public key isnt quite like ours + if (!this._cachedCorrectKey && this._provider?.publicKey) + this._cachedCorrectKey = new PublicKey( + this._provider.publicKey.toBase58(), + ); + + return this._cachedCorrectKey || null; } async signTransaction(transaction: Transaction) { @@ -70,32 +77,32 @@ export class PhantomWalletAdapter if ((window as any)?.solana?.isPhantom) { provider = (window as any).solana; } else { - window.open("https://phantom.app/", "_blank"); + window.open('https://phantom.app/', '_blank'); notify({ - message: "Phantom Error", - description: "Please install Phantom wallet from Chrome ", + message: 'Phantom Error', + description: 'Please install Phantom wallet from Chrome ', }); return; } provider.on('connect', () => { this._provider = provider; - this.emit("connect"); - }) + this.emit('connect'); + }); if (!provider.isConnected) { await provider.connect(); } this._provider = provider; - this.emit("connect"); - } + this.emit('connect'); + }; disconnect() { if (this._provider) { this._provider.disconnect(); this._provider = undefined; - this.emit("disconnect"); + this.emit('disconnect'); } } } diff --git a/packages/common/src/wallet-adapters/solong/index.tsx b/packages/common/src/wallet-adapters/solong/index.tsx index 4f2bcc6..d773d0e 100644 --- a/packages/common/src/wallet-adapters/solong/index.tsx +++ b/packages/common/src/wallet-adapters/solong/index.tsx @@ -1,7 +1,7 @@ -import EventEmitter from "eventemitter3"; -import {PublicKey, Transaction} from "@solana/web3.js"; -import { WalletAdapter } from "@solana/wallet-base"; -import { notify } from "../../utils/notifications"; +import EventEmitter from 'eventemitter3'; +import { PublicKey, Transaction } from '@solana/web3.js'; +import { WalletAdapter } from '@solana/wallet-base'; +import { notify } from '../../utils/notifications'; export class SolongWalletAdapter extends EventEmitter implements WalletAdapter { _publicKey: PublicKey | null; @@ -32,8 +32,8 @@ export class SolongWalletAdapter extends EventEmitter implements WalletAdapter { if ((window as any).solong === undefined) { notify({ - message: "Solong Error", - description: "Please install solong wallet from Chrome ", + message: 'Solong Error', + description: 'Please install solong wallet from Chrome ', }); return; } @@ -43,7 +43,7 @@ export class SolongWalletAdapter extends EventEmitter implements WalletAdapter { .selectAccount() .then((account: any) => { this._publicKey = new PublicKey(account); - this.emit("connect", this._publicKey); + this.emit('connect', this._publicKey); }) .catch(() => { this.disconnect(); @@ -56,7 +56,7 @@ export class SolongWalletAdapter extends EventEmitter implements WalletAdapter { disconnect() { if (this._publicKey) { this._publicKey = null; - this.emit("disconnect"); + this.emit('disconnect'); } } } diff --git a/packages/common/src/wallet-adapters/solong_adapter.tsx b/packages/common/src/wallet-adapters/solong_adapter.tsx index aef7dd6..f050a44 100644 --- a/packages/common/src/wallet-adapters/solong_adapter.tsx +++ b/packages/common/src/wallet-adapters/solong_adapter.tsx @@ -1,6 +1,6 @@ -import EventEmitter from "eventemitter3"; -import { PublicKey } from "@solana/web3.js"; -import { notify } from "../utils/notifications"; +import EventEmitter from 'eventemitter3'; +import { PublicKey } from '@solana/web3.js'; +import { notify } from '../utils/notifications'; export class SolongAdapter extends EventEmitter { _publicKey: any; @@ -27,8 +27,8 @@ export class SolongAdapter extends EventEmitter { if ((window as any).solong === undefined) { notify({ - message: "Solong Error", - description: "Please install solong wallet from Chrome ", + message: 'Solong Error', + description: 'Please install solong wallet from Chrome ', }); return; } @@ -38,7 +38,7 @@ export class SolongAdapter extends EventEmitter { .selectAccount() .then((account: any) => { this._publicKey = new PublicKey(account); - this.emit("connect", this._publicKey); + this.emit('connect', this._publicKey); }) .catch(() => { this.disconnect(); @@ -51,7 +51,7 @@ export class SolongAdapter extends EventEmitter { disconnect() { if (this._publicKey) { this._publicKey = null; - this.emit("disconnect"); + this.emit('disconnect'); } } } diff --git a/packages/common/src/wallet-adapters/torus/index.tsx b/packages/common/src/wallet-adapters/torus/index.tsx new file mode 100644 index 0000000..39495bd --- /dev/null +++ b/packages/common/src/wallet-adapters/torus/index.tsx @@ -0,0 +1,100 @@ +import EventEmitter from 'eventemitter3'; +import { Account, PublicKey, Transaction } from '@solana/web3.js'; +import { WalletAdapter } from '@solana/wallet-base'; +import OpenLogin from '@toruslabs/openlogin'; +import { getED25519Key } from '@toruslabs/openlogin-ed25519'; + +const getSolanaPrivateKey = (openloginKey: string) => { + const { sk } = getED25519Key(openloginKey); + return sk; +}; + +export class TorusWalletAdapter extends EventEmitter implements WalletAdapter { + _provider: OpenLogin | undefined; + endpoint: string; + providerUrl: string; + account: Account | undefined; + image: string = ''; + name: string = ''; + + constructor(providerUrl: string, endpoint: string) { + super(); + this.connect = this.connect.bind(this); + this.endpoint = endpoint; + this.providerUrl = providerUrl; + } + + async signAllTransactions( + transactions: Transaction[], + ): Promise { + if (this.account) { + let account = this.account; + transactions.forEach(t => t.partialSign(account)); + } + + return transactions; + } + + get publicKey() { + return this.account?.publicKey || null; + } + + async signTransaction(transaction: Transaction) { + if (this.account) { + transaction.partialSign(this.account); + } + + return transaction; + } + + connect = async () => { + const clientId = + process.env.REACT_APP_CLIENT_ID || + 'BNxdRWx08cSTPlzMAaShlM62d4f8Tp6racfnCg_gaH0XQ1NfSGo3h5B_IkLtgSnPMhlxsSvhqugWm0x8x-VkUXA'; + this._provider = new OpenLogin({ + clientId, + network: 'testnet', // mainnet, testnet, development + uxMode: 'popup', + }); + + try { + await this._provider.init(); + } catch (ex) { + console.error('init failed', ex); + } + + console.error(this._provider?.state.store); + + if (this._provider.privKey) { + const privateKey = this._provider.privKey; + const secretKey = getSolanaPrivateKey(privateKey); + this.account = new Account(secretKey); + } else { + try { + const { privKey } = await this._provider.login({ + loginProvider: 'unselected', + } as any); + const secretKey = getSolanaPrivateKey(privKey); + this.account = new Account(secretKey); + } catch (ex) { + console.error('login failed', ex); + } + } + + this.name = this._provider?.state.store.get('name'); + this.image = this._provider?.state.store.get('profileImage'); + debugger; + + this.emit('connect'); + }; + + disconnect = async () => { + console.log('Disconnecting...'); + if (this._provider) { + await this._provider.logout(); + await this._provider._cleanup(); + this._provider = undefined; + this.emit('disconnect'); + } + }; +} diff --git a/packages/proposals/.env b/packages/governance/.env similarity index 100% rename from packages/proposals/.env rename to packages/governance/.env diff --git a/packages/proposals/.env.production b/packages/governance/.env.production similarity index 100% rename from packages/proposals/.env.production rename to packages/governance/.env.production diff --git a/packages/proposals/craco.config.js b/packages/governance/craco.config.js similarity index 95% rename from packages/proposals/craco.config.js rename to packages/governance/craco.config.js index bd78054..1ce0585 100644 --- a/packages/proposals/craco.config.js +++ b/packages/governance/craco.config.js @@ -10,7 +10,7 @@ module.exports = { webpack: { configure: (webpackConfig, { env, paths }) => { paths.appBuild = webpackConfig.output.path = path.resolve( - './../../build/proposals', + './../../build/governance', ); return webpackConfig; }, diff --git a/packages/proposals/package.json b/packages/governance/package.json similarity index 91% rename from packages/proposals/package.json rename to packages/governance/package.json index 484fa6f..b7a3fed 100644 --- a/packages/proposals/package.json +++ b/packages/governance/package.json @@ -1,5 +1,5 @@ { - "name": "proposals", + "name": "governance", "version": "0.0.1", "dependencies": { "@ant-design/icons": "^4.4.0", @@ -12,7 +12,8 @@ "@solana/spl-token": "0.0.13", "@solana/spl-token-swap": "0.1.0", "@solana/wallet-base": "0.0.1", - "@solana/web3.js": "^0.86.2", + "@solana/wallet-ledger": "0.0.1", + "@solana/web3.js": "^1.5.0", "@testing-library/jest-dom": "^4.2.4", "@testing-library/react": "^9.5.0", "@testing-library/user-event": "^7.2.1", @@ -59,8 +60,8 @@ "localnet:down": "solana-localnet down", "localnet:logs": "solana-localnet logs -f", "predeploy": "git pull --ff-only && yarn && yarn build", - "deploy": "gh-pages -d ../../build/proposals --repo https://github.com/solana-labs/oyster-gov", - "deploy:ar": "arweave deploy-dir ../../build/proposals --key-file ", + "deploy": "gh-pages -d ../../build/governance --repo https://github.com/solana-labs/oyster-gov", + "deploy:ar": "arweave deploy-dir ../../build/governance --key-file ", "format:fix": "prettier --write \"**/*.+(js|jsx|ts|tsx|json|css|md)\"" }, "eslintConfig": { diff --git a/packages/proposals/public/index.html b/packages/governance/public/index.html similarity index 100% rename from packages/proposals/public/index.html rename to packages/governance/public/index.html diff --git a/packages/proposals/public/logo.ico b/packages/governance/public/logo.ico similarity index 100% rename from packages/proposals/public/logo.ico rename to packages/governance/public/logo.ico diff --git a/packages/proposals/public/manifest.json b/packages/governance/public/manifest.json similarity index 100% rename from packages/proposals/public/manifest.json rename to packages/governance/public/manifest.json diff --git a/packages/proposals/public/robots.txt b/packages/governance/public/robots.txt similarity index 100% rename from packages/proposals/public/robots.txt rename to packages/governance/public/robots.txt diff --git a/packages/proposals/public/splash.svg b/packages/governance/public/splash.svg similarity index 100% rename from packages/proposals/public/splash.svg rename to packages/governance/public/splash.svg diff --git a/packages/proposals/src/App.less b/packages/governance/src/App.less similarity index 100% rename from packages/proposals/src/App.less rename to packages/governance/src/App.less diff --git a/packages/proposals/src/App.tsx b/packages/governance/src/App.tsx similarity index 100% rename from packages/proposals/src/App.tsx rename to packages/governance/src/App.tsx diff --git a/packages/proposals/src/actions/addCustomSingleSignerTransaction.ts b/packages/governance/src/actions/addCustomSingleSignerTransaction.ts similarity index 80% rename from packages/proposals/src/actions/addCustomSingleSignerTransaction.ts rename to packages/governance/src/actions/addCustomSingleSignerTransaction.ts index 1d5af6a..5fd87ec 100644 --- a/packages/proposals/src/actions/addCustomSingleSignerTransaction.ts +++ b/packages/governance/src/actions/addCustomSingleSignerTransaction.ts @@ -1,30 +1,28 @@ import { Account, Connection, - Message, PublicKey, SystemProgram, TransactionInstruction, } from '@solana/web3.js'; import { contexts, utils, models, ParsedAccount } from '@oyster/common'; import { - CustomSingleSignerTimelockTransactionLayout, - TimelockSet, - TimelockState, -} from '../models/timelock'; + GOVERNANCE_AUTHORITY_SEED, + CustomSingleSignerTransactionLayout, + Proposal, + ProposalState, +} from '../models/governance'; import { addCustomSingleSignerTransactionInstruction } from '../models/addCustomSingleSignerTransaction'; -import { pingInstruction } from '../models/ping'; -import { serializeInstruction } from '../utils/serialize'; const { sendTransaction } = contexts.Connection; -const { notify, shortvec, toUTF8Array, fromUTF8Array } = utils; +const { notify } = utils; const { approve } = models; export const addCustomSingleSignerTransaction = async ( connection: Connection, wallet: any, - proposal: ParsedAccount, - state: ParsedAccount, + proposal: ParsedAccount, + state: ParsedAccount, sigAccount: PublicKey, slot: string, instruction: string, @@ -36,7 +34,7 @@ export const addCustomSingleSignerTransaction = async ( let instructions: TransactionInstruction[] = []; const rentExempt = await connection.getMinimumBalanceForRentExemption( - CustomSingleSignerTimelockTransactionLayout.span, + CustomSingleSignerTransactionLayout.span, ); const txnKey = new Account(); @@ -45,13 +43,13 @@ export const addCustomSingleSignerTransaction = async ( fromPubkey: wallet.publicKey, newAccountPubkey: txnKey.publicKey, lamports: rentExempt, - space: CustomSingleSignerTimelockTransactionLayout.span, - programId: PROGRAM_IDS.timelock.programId, + space: CustomSingleSignerTransactionLayout.span, + programId: PROGRAM_IDS.governance.programId, }); const [authority] = await PublicKey.findProgramAddress( - [proposal.pubkey.toBuffer()], - PROGRAM_IDS.timelock.programId, + [Buffer.from(GOVERNANCE_AUTHORITY_SEED), proposal.pubkey.toBuffer()], + PROGRAM_IDS.governance.programId, ); signers.push(txnKey); diff --git a/packages/proposals/src/actions/addSigner.ts b/packages/governance/src/actions/addSigner.ts similarity index 87% rename from packages/proposals/src/actions/addSigner.ts rename to packages/governance/src/actions/addSigner.ts index 5f5dfc0..9263bd3 100644 --- a/packages/proposals/src/actions/addSigner.ts +++ b/packages/governance/src/actions/addSigner.ts @@ -12,7 +12,11 @@ import { actions, } from '@oyster/common'; -import { TimelockSet, TimelockState } from '../models/timelock'; +import { + GOVERNANCE_AUTHORITY_SEED, + Proposal, + ProposalState, +} from '../models/governance'; import { AccountLayout } from '@solana/spl-token'; import { addSignerInstruction } from '../models/addSigner'; const { createTokenAccount } = actions; @@ -23,8 +27,8 @@ const { approve } = models; export const addSigner = async ( connection: Connection, wallet: any, - proposal: ParsedAccount, - state: ParsedAccount, + proposal: ParsedAccount, + state: ParsedAccount, adminAccount: PublicKey, newSignatoryAccountOwner: PublicKey, ) => { @@ -47,8 +51,8 @@ export const addSigner = async ( ); const [mintAuthority] = await PublicKey.findProgramAddress( - [proposal.pubkey.toBuffer()], - PROGRAM_IDS.timelock.programId, + [Buffer.from(GOVERNANCE_AUTHORITY_SEED), proposal.pubkey.toBuffer()], + PROGRAM_IDS.governance.programId, ); const transferAuthority = approve( diff --git a/packages/proposals/src/actions/createProposal.ts b/packages/governance/src/actions/createProposal.ts similarity index 69% rename from packages/proposals/src/actions/createProposal.ts rename to packages/governance/src/actions/createProposal.ts index a87d867..742e81b 100644 --- a/packages/proposals/src/actions/createProposal.ts +++ b/packages/governance/src/actions/createProposal.ts @@ -5,15 +5,22 @@ import { SystemProgram, TransactionInstruction, } from '@solana/web3.js'; -import { contexts, utils, actions, ParsedAccount } from '@oyster/common'; +import { + contexts, + utils, + actions, + ParsedAccount, + SequenceType, +} from '@oyster/common'; import { AccountLayout, MintLayout } from '@solana/spl-token'; -import { initTimelockSetInstruction } from '../models/initTimelockSet'; +import { initProposalInstruction } from '../models/initProposal'; import { - TimelockConfig, - TimelockSetLayout, - TimelockStateLayout, -} from '../models/timelock'; + GOVERNANCE_AUTHORITY_SEED, + Governance, + ProposalLayout, + ProposalStateLayout, +} from '../models/governance'; const { cache } = contexts.Accounts; const { sendTransactions } = contexts.Connection; @@ -26,7 +33,7 @@ export const createProposal = async ( name: string, description: string, useGovernance: boolean, - timelockConfig: ParsedAccount, + governance: ParsedAccount, ): Promise => { const PROGRAM_IDS = utils.programIds(); @@ -44,12 +51,12 @@ export const createProposal = async ( await cache.queryMint( connection, useGovernance - ? timelockConfig.info.governanceMint - : timelockConfig.info.councilMint, + ? governance.info.governanceMint + : governance.info.councilMint!, ) ).decimals; - const timelockSetKey = new Account(); + const proposalKey = new Account(); const { sigMint, @@ -62,8 +69,6 @@ export const createProposal = async ( adminValidationAccount, adminDestinationAccount, sigDestinationAccount, - yesVoteDumpAccount, - noVoteDumpAccount, sourceHoldingAccount, authority, instructions: associatedInstructions, @@ -72,54 +77,54 @@ export const createProposal = async ( wallet, accountRentExempt, mintRentExempt, - timelockConfig, + governance, useGovernance, sourceMintDecimals, - timelockSetKey, + proposalKey, ); - let createTimelockAccountsSigners: Account[] = []; - let createTimelockAccountsInstructions: TransactionInstruction[] = []; + let createGovernanceAccountsSigners: Account[] = []; + let createGovernanceAccountsInstructions: TransactionInstruction[] = []; - const timelockRentExempt = await connection.getMinimumBalanceForRentExemption( - TimelockSetLayout.span, + const proposalRentExempt = await connection.getMinimumBalanceForRentExemption( + ProposalLayout.span, ); - const timelockStateRentExempt = await connection.getMinimumBalanceForRentExemption( - TimelockStateLayout.span, + const proposalStateRentExempt = await connection.getMinimumBalanceForRentExemption( + ProposalStateLayout.span, ); - const timelockStateKey = new Account(); + const proposalStateKey = new Account(); - const uninitializedTimelockStateInstruction = SystemProgram.createAccount({ + const uninitializedProposalStateInstruction = SystemProgram.createAccount({ fromPubkey: wallet.publicKey, - newAccountPubkey: timelockStateKey.publicKey, - lamports: timelockStateRentExempt, - space: TimelockStateLayout.span, - programId: PROGRAM_IDS.timelock.programId, + newAccountPubkey: proposalStateKey.publicKey, + lamports: proposalStateRentExempt, + space: ProposalStateLayout.span, + programId: PROGRAM_IDS.governance.programId, }); - signers.push(timelockStateKey); - createTimelockAccountsSigners.push(timelockStateKey); - createTimelockAccountsInstructions.push( - uninitializedTimelockStateInstruction, + signers.push(proposalStateKey); + createGovernanceAccountsSigners.push(proposalStateKey); + createGovernanceAccountsInstructions.push( + uninitializedProposalStateInstruction, ); - const uninitializedTimelockSetInstruction = SystemProgram.createAccount({ + const uninitializedProposalInstruction = SystemProgram.createAccount({ fromPubkey: wallet.publicKey, - newAccountPubkey: timelockSetKey.publicKey, - lamports: timelockRentExempt, - space: TimelockSetLayout.span, - programId: PROGRAM_IDS.timelock.programId, + newAccountPubkey: proposalKey.publicKey, + lamports: proposalRentExempt, + space: ProposalLayout.span, + programId: PROGRAM_IDS.governance.programId, }); - signers.push(timelockSetKey); - createTimelockAccountsSigners.push(timelockSetKey); - createTimelockAccountsInstructions.push(uninitializedTimelockSetInstruction); + signers.push(proposalKey); + createGovernanceAccountsSigners.push(proposalKey); + createGovernanceAccountsInstructions.push(uninitializedProposalInstruction); instructions.push( - initTimelockSetInstruction( - timelockStateKey.publicKey, - timelockSetKey.publicKey, - timelockConfig.pubkey, + initProposalInstruction( + proposalStateKey.publicKey, + proposalKey.publicKey, + governance.pubkey, sigMint, adminMint, voteMint, @@ -130,12 +135,10 @@ export const createProposal = async ( voteValidationAccount, adminDestinationAccount, sigDestinationAccount, - yesVoteDumpAccount, - noVoteDumpAccount, sourceHoldingAccount, useGovernance - ? timelockConfig.info.governanceMint - : timelockConfig.info.councilMint, + ? governance.info.governanceMint + : governance.info.councilMint!, authority, description, name, @@ -154,11 +157,10 @@ export const createProposal = async ( wallet, [ ...associatedInstructions, - createTimelockAccountsInstructions, + createGovernanceAccountsInstructions, instructions, ], - [...associatedSigners, createTimelockAccountsSigners, signers], - true, + [...associatedSigners, createGovernanceAccountsSigners, signers], ); notify({ @@ -167,7 +169,7 @@ export const createProposal = async ( description: `Transaction - ${tx}`, }); - return timelockSetKey; + return proposalKey; } catch (ex) { console.error(ex); throw new Error(); @@ -185,8 +187,6 @@ interface ValidationReturn { adminValidationAccount: PublicKey; adminDestinationAccount: PublicKey; sigDestinationAccount: PublicKey; - yesVoteDumpAccount: PublicKey; - noVoteDumpAccount: PublicKey; sourceHoldingAccount: PublicKey; authority: PublicKey; signers: Account[][]; @@ -197,7 +197,7 @@ async function getAssociatedAccountsAndInstructions( wallet: any, accountRentExempt: number, mintRentExempt: number, - timelockConfig: ParsedAccount, + governance: ParsedAccount, useGovernance: boolean, sourceMintDecimals: number, newProposalKey: Account, @@ -205,8 +205,11 @@ async function getAssociatedAccountsAndInstructions( const PROGRAM_IDS = utils.programIds(); const [authority] = await PublicKey.findProgramAddress( - [newProposalKey.publicKey.toBuffer()], - PROGRAM_IDS.timelock.programId, + [ + Buffer.from(GOVERNANCE_AUTHORITY_SEED), + newProposalKey.publicKey.toBuffer(), + ], + PROGRAM_IDS.governance.programId, ); let mintSigners: Account[] = []; @@ -318,31 +321,13 @@ async function getAssociatedAccountsAndInstructions( let holdingSigners: Account[] = []; let holdingInstructions: TransactionInstruction[] = []; - const yesVoteDumpAccount = createTokenAccount( - holdingInstructions, - wallet.publicKey, - accountRentExempt, - yesVoteMint, - authority, - holdingSigners, - ); - - const noVoteDumpAccount = createTokenAccount( - holdingInstructions, - wallet.publicKey, - accountRentExempt, - noVoteMint, - authority, - holdingSigners, - ); - const sourceHoldingAccount = createTokenAccount( holdingInstructions, wallet.publicKey, accountRentExempt, useGovernance - ? timelockConfig.info.governanceMint - : timelockConfig.info.councilMint, + ? governance.info.governanceMint + : governance.info.councilMint!, authority, holdingSigners, ); @@ -358,8 +343,6 @@ async function getAssociatedAccountsAndInstructions( adminValidationAccount, adminDestinationAccount, sigDestinationAccount, - yesVoteDumpAccount, - noVoteDumpAccount, sourceHoldingAccount, authority, signers: [ diff --git a/packages/proposals/src/actions/depositSourceTokensAndVote.ts b/packages/governance/src/actions/depositSourceTokensAndVote.ts similarity index 88% rename from packages/proposals/src/actions/depositSourceTokensAndVote.ts rename to packages/governance/src/actions/depositSourceTokensAndVote.ts index 382d561..f767845 100644 --- a/packages/proposals/src/actions/depositSourceTokensAndVote.ts +++ b/packages/governance/src/actions/depositSourceTokensAndVote.ts @@ -12,7 +12,12 @@ import { actions, } from '@oyster/common'; -import { TimelockConfig, TimelockSet, TimelockState } from '../models/timelock'; +import { + GOVERNANCE_AUTHORITY_SEED, + Governance, + Proposal, + ProposalState, +} from '../models/governance'; import { AccountLayout } from '@solana/spl-token'; @@ -23,20 +28,20 @@ import { createEmptyGovernanceVotingRecordInstruction } from '../models/createEm import { voteInstruction } from '../models/vote'; const { createTokenAccount } = actions; -const { sendTransactions } = contexts.Connection; +const { sendTransactions, SequenceType } = contexts.Connection; const { notify } = utils; const { approve } = models; export const depositSourceTokensAndVote = async ( connection: Connection, wallet: any, - proposal: ParsedAccount, + proposal: ParsedAccount, existingVoteAccount: PublicKey | undefined, existingYesVoteAccount: PublicKey | undefined, existingNoVoteAccount: PublicKey | undefined, sourceAccount: PublicKey, - timelockConfig: ParsedAccount, - state: ParsedAccount, + governance: ParsedAccount, + state: ParsedAccount, yesVotingTokenAmount: number, noVotingTokenAmount: number, ) => { @@ -66,11 +71,12 @@ export const depositSourceTokensAndVote = async ( const [governanceVotingRecord] = await PublicKey.findProgramAddress( [ - PROGRAM_IDS.timelock.programId.toBuffer(), + Buffer.from(GOVERNANCE_AUTHORITY_SEED), + PROGRAM_IDS.governance.programId.toBuffer(), proposal.pubkey.toBuffer(), existingVoteAccount.toBuffer(), ], - PROGRAM_IDS.timelock.programId, + PROGRAM_IDS.governance.programId, ); if (needToCreateGovAccountToo) { @@ -107,8 +113,8 @@ export const depositSourceTokensAndVote = async ( } const [mintAuthority] = await PublicKey.findProgramAddress( - [proposal.pubkey.toBuffer()], - PROGRAM_IDS.timelock.programId, + [Buffer.from(GOVERNANCE_AUTHORITY_SEED), proposal.pubkey.toBuffer()], + PROGRAM_IDS.governance.programId, ); const depositAuthority = approve( @@ -160,7 +166,7 @@ export const depositSourceTokensAndVote = async ( proposal.info.noVotingMint, proposal.info.sourceMint, proposal.pubkey, - timelockConfig.pubkey, + governance.pubkey, voteAuthority.publicKey, mintAuthority, yesVotingTokenAmount, @@ -193,7 +199,7 @@ export const depositSourceTokensAndVote = async ( wallet, [depositInstructions, voteInstructions], [depositSigners, voteSigners], - true, + SequenceType.Sequential, ); notify({ diff --git a/packages/governance/src/actions/execute.ts b/packages/governance/src/actions/execute.ts new file mode 100644 index 0000000..ab274ca --- /dev/null +++ b/packages/governance/src/actions/execute.ts @@ -0,0 +1,74 @@ +import { + Account, + Connection, + Message, + TransactionInstruction, +} from '@solana/web3.js'; +import { + contexts, + utils, + ParsedAccount, + sendTransactionWithRetry, +} from '@oyster/common'; + +import { + Proposal, + ProposalState, + GovernanceTransaction, +} from '../models/governance'; +import { executeInstruction } from '../models/execute'; +import { LABELS } from '../constants'; +import { getMessageAccountInfos } from '../utils/transactions'; +const { notify } = utils; + +export const execute = async ( + connection: Connection, + wallet: any, + proposal: ParsedAccount, + state: ParsedAccount, + transaction: ParsedAccount, +) => { + let signers: Account[] = []; + let instructions: TransactionInstruction[] = []; + const actualMessage = decodeBufferIntoMessage(transaction.info.instruction); + const accountInfos = getMessageAccountInfos(actualMessage); + + instructions.push( + executeInstruction( + transaction.pubkey, + state.pubkey, + proposal.pubkey, + actualMessage.accountKeys[actualMessage.instructions[0].programIdIndex], + proposal.info.config, + accountInfos, + ), + ); + + notify({ + message: LABELS.EXECUTING, + description: LABELS.PLEASE_WAIT, + type: 'warn', + }); + + try { + let tx = await sendTransactionWithRetry( + connection, + wallet, + instructions, + signers, + ); + + notify({ + message: LABELS.EXECUTED, + type: 'success', + description: LABELS.TRANSACTION + ` ${tx}`, + }); + } catch (ex) { + console.error(ex); + throw new Error(); + } +}; + +function decodeBufferIntoMessage(instruction: number[]): Message { + return Message.from(instruction); +} diff --git a/packages/proposals/src/actions/mintSourceTokens.ts b/packages/governance/src/actions/mintSourceTokens.ts similarity index 83% rename from packages/proposals/src/actions/mintSourceTokens.ts rename to packages/governance/src/actions/mintSourceTokens.ts index f14dae4..8c93ff2 100644 --- a/packages/proposals/src/actions/mintSourceTokens.ts +++ b/packages/governance/src/actions/mintSourceTokens.ts @@ -4,9 +4,15 @@ import { PublicKey, TransactionInstruction, } from '@solana/web3.js'; -import { contexts, utils, ParsedAccount, actions } from '@oyster/common'; +import { + contexts, + utils, + ParsedAccount, + actions, + SequenceType, +} from '@oyster/common'; -import { TimelockConfig } from '../models/timelock'; +import { Governance } from '../models/governance'; import { AccountLayout, Token } from '@solana/spl-token'; import { LABELS } from '../constants'; const { createTokenAccount } = actions; @@ -20,7 +26,7 @@ export interface SourceEntryInterface { export const mintSourceTokens = async ( connection: Connection, wallet: any, - timelockConfig: ParsedAccount, + governance: ParsedAccount, useGovernance: boolean, entries: SourceEntryInterface[], setSavePerc: (num: number) => void, @@ -44,8 +50,8 @@ export const mintSourceTokens = async ( wallet.publicKey, accountRentExempt, useGovernance - ? timelockConfig.info.governanceMint - : timelockConfig.info.councilMint, + ? governance.info.governanceMint + : governance.info.councilMint!, e.owner, signers, ); @@ -54,8 +60,8 @@ export const mintSourceTokens = async ( Token.createMintToInstruction( PROGRAM_IDS.token, useGovernance - ? timelockConfig.info.governanceMint - : timelockConfig.info.councilMint, + ? governance.info.governanceMint + : governance.info.councilMint!, e.sourceAccount, wallet.publicKey, [], @@ -79,12 +85,12 @@ export const mintSourceTokens = async ( wallet, allInstructions, allSigners, - true, + SequenceType.Sequential, 'singleGossip', (_txId: string, index: number) => { setSavePerc(Math.round(100 * ((index + 1) / allInstructions.length))); }, - (_txId: string, index: number) => { + (_reason: string, index: number) => { setSavePerc(Math.round(100 * ((index + 1) / allInstructions.length))); onFailedTxn(index); return true; // keep going even on failed save diff --git a/packages/proposals/src/actions/registerProgramGovernance.ts b/packages/governance/src/actions/registerProgramGovernance.ts similarity index 55% rename from packages/proposals/src/actions/registerProgramGovernance.ts rename to packages/governance/src/actions/registerProgramGovernance.ts index cfb0120..2ba9724 100644 --- a/packages/proposals/src/actions/registerProgramGovernance.ts +++ b/packages/governance/src/actions/registerProgramGovernance.ts @@ -4,19 +4,12 @@ import { PublicKey, TransactionInstruction, } from '@solana/web3.js'; -import { contexts, utils, actions } from '@oyster/common'; +import { contexts, utils, actions, SequenceType } from '@oyster/common'; import { AccountLayout, MintLayout, Token } from '@solana/spl-token'; -import { - ConsensusAlgorithm, - ExecutionType, - TimelockConfig, - TimelockType, - VotingEntryRule, -} from '../models/timelock'; -import { initTimelockConfigInstruction } from '../models/initTimelockConfig'; +import { GOVERNANCE_AUTHORITY_SEED, Governance } from '../models/governance'; +import { createGovernanceInstruction } from '../models/createGovernance'; import BN from 'bn.js'; -import { createEmptyTimelockConfigInstruction } from '../models/createEmptyTimelockConfig'; const { sendTransactions } = contexts.Connection; const { createMint, createTokenAccount } = actions; @@ -25,7 +18,8 @@ const { notify } = utils; export const registerProgramGovernance = async ( connection: Connection, wallet: any, - uninitializedTimelockConfig: Partial, + uninitializedGovernance: Partial, + useCouncil: boolean, ): Promise => { const PROGRAM_IDS = utils.programIds(); let signers: Account[] = []; @@ -40,13 +34,13 @@ export const registerProgramGovernance = async ( AccountLayout.span, ); - if (!uninitializedTimelockConfig.program) - uninitializedTimelockConfig.program = new Account().publicKey; // Random generation if none given + if (!uninitializedGovernance.program) + uninitializedGovernance.program = new Account().publicKey; // Random generation if none given - if (!uninitializedTimelockConfig.councilMint) { + if (!uninitializedGovernance.councilMint && useCouncil) { // Initialize the mint, an account for the admin, and give them one council token // to start their lives with. - uninitializedTimelockConfig.councilMint = createMint( + uninitializedGovernance.councilMint = createMint( mintInstructions, wallet.publicKey, mintRentExempt, @@ -60,7 +54,7 @@ export const registerProgramGovernance = async ( mintInstructions, wallet.publicKey, accountRentExempt, - uninitializedTimelockConfig.councilMint, + uninitializedGovernance.councilMint, wallet.publicKey, mintSigners, ); @@ -68,7 +62,7 @@ export const registerProgramGovernance = async ( mintInstructions.push( Token.createMintToInstruction( PROGRAM_IDS.token, - uninitializedTimelockConfig.councilMint, + uninitializedGovernance.councilMint, adminsCouncilToken, wallet.publicKey, [], @@ -77,10 +71,10 @@ export const registerProgramGovernance = async ( ); } - if (!uninitializedTimelockConfig.governanceMint) { + if (!uninitializedGovernance.governanceMint) { // Initialize the mint, an account for the admin, and give them one governance token // to start their lives with. - uninitializedTimelockConfig.governanceMint = createMint( + uninitializedGovernance.governanceMint = createMint( mintInstructions, wallet.publicKey, mintRentExempt, @@ -94,7 +88,7 @@ export const registerProgramGovernance = async ( mintInstructions, wallet.publicKey, accountRentExempt, - uninitializedTimelockConfig.governanceMint, + uninitializedGovernance.governanceMint, wallet.publicKey, mintSigners, ); @@ -102,7 +96,7 @@ export const registerProgramGovernance = async ( mintInstructions.push( Token.createMintToInstruction( PROGRAM_IDS.token, - uninitializedTimelockConfig.governanceMint, + uninitializedGovernance.governanceMint, adminsGovernanceToken, wallet.publicKey, [], @@ -111,40 +105,33 @@ export const registerProgramGovernance = async ( ); } - const [timelockConfigKey] = await PublicKey.findProgramAddress( + const [governanceKey] = await PublicKey.findProgramAddress( [ - PROGRAM_IDS.timelock.programId.toBuffer(), - uninitializedTimelockConfig.governanceMint.toBuffer(), - uninitializedTimelockConfig.councilMint.toBuffer(), - uninitializedTimelockConfig.program.toBuffer(), + Buffer.from(GOVERNANCE_AUTHORITY_SEED), + uninitializedGovernance.program.toBuffer(), ], - PROGRAM_IDS.timelock.programId, + PROGRAM_IDS.governance.programId, + ); + + const [programDataAccount] = await PublicKey.findProgramAddress( + [uninitializedGovernance.program.toBuffer()], + PROGRAM_IDS.bpf_upgrade_loader, ); instructions.push( - createEmptyTimelockConfigInstruction( - timelockConfigKey, - uninitializedTimelockConfig.program, - uninitializedTimelockConfig.governanceMint, - uninitializedTimelockConfig.councilMint, + createGovernanceInstruction( + governanceKey, + uninitializedGovernance.program, + programDataAccount, wallet.publicKey, - ), - ); - instructions.push( - initTimelockConfigInstruction( - timelockConfigKey, - uninitializedTimelockConfig.program, - uninitializedTimelockConfig.governanceMint, - uninitializedTimelockConfig.councilMint, - uninitializedTimelockConfig.consensusAlgorithm || - ConsensusAlgorithm.Majority, - uninitializedTimelockConfig.executionType || ExecutionType.Independent, - uninitializedTimelockConfig.timelockType || - TimelockType.CustomSingleSignerV1, - uninitializedTimelockConfig.votingEntryRule || VotingEntryRule.Anytime, - uninitializedTimelockConfig.minimumSlotWaitingPeriod || new BN(0), - uninitializedTimelockConfig.timeLimit || new BN(0), - uninitializedTimelockConfig.name || '', + uninitializedGovernance.governanceMint, + + uninitializedGovernance.voteThreshold!, + uninitializedGovernance.minimumSlotWaitingPeriod || new BN(0), + uninitializedGovernance.timeLimit || new BN(0), + uninitializedGovernance.name || '', + wallet.publicKey, + uninitializedGovernance.councilMint, ), ); @@ -162,7 +149,7 @@ export const registerProgramGovernance = async ( ? [mintInstructions, instructions] : [instructions], mintInstructions.length ? [mintSigners, signers] : [signers], - true, + SequenceType.Sequential, ); notify({ @@ -171,7 +158,7 @@ export const registerProgramGovernance = async ( description: `Transaction - ${tx}`, }); - return timelockConfigKey; + return governanceKey; } catch (ex) { console.error(ex); throw new Error(); diff --git a/packages/proposals/src/actions/removeSigner.ts b/packages/governance/src/actions/removeSigner.ts similarity index 86% rename from packages/proposals/src/actions/removeSigner.ts rename to packages/governance/src/actions/removeSigner.ts index e2357e2..9dd2747 100644 --- a/packages/proposals/src/actions/removeSigner.ts +++ b/packages/governance/src/actions/removeSigner.ts @@ -6,7 +6,7 @@ import { } from '@solana/web3.js'; import { contexts, utils, models, ParsedAccount } from '@oyster/common'; -import { TimelockSet } from '../models/timelock'; +import { GOVERNANCE_AUTHORITY_SEED, Proposal } from '../models/governance'; import { removeSignerInstruction } from '../models/removeSigner'; const { sendTransaction } = contexts.Connection; const { notify } = utils; @@ -15,7 +15,7 @@ const { approve } = models; export const removeSigner = async ( connection: Connection, wallet: any, - proposal: ParsedAccount, + proposal: ParsedAccount, adminAccount: PublicKey, sigAccount: PublicKey, ) => { @@ -25,8 +25,8 @@ export const removeSigner = async ( let instructions: TransactionInstruction[] = []; const [mintAuthority] = await PublicKey.findProgramAddress( - [proposal.pubkey.toBuffer()], - PROGRAM_IDS.timelock.programId, + [Buffer.from(GOVERNANCE_AUTHORITY_SEED), proposal.pubkey.toBuffer()], + PROGRAM_IDS.governance.programId, ); const transferAuthority = approve( diff --git a/packages/proposals/src/actions/sign.ts b/packages/governance/src/actions/sign.ts similarity index 83% rename from packages/proposals/src/actions/sign.ts rename to packages/governance/src/actions/sign.ts index 30e9709..725deed 100644 --- a/packages/proposals/src/actions/sign.ts +++ b/packages/governance/src/actions/sign.ts @@ -6,7 +6,11 @@ import { } from '@solana/web3.js'; import { contexts, utils, models, ParsedAccount } from '@oyster/common'; -import { TimelockSet, TimelockState } from '../models/timelock'; +import { + GOVERNANCE_AUTHORITY_SEED, + Proposal, + ProposalState, +} from '../models/governance'; import { signInstruction } from '../models/sign'; const { sendTransaction } = contexts.Connection; @@ -16,8 +20,8 @@ const { approve } = models; export const sign = async ( connection: Connection, wallet: any, - proposal: ParsedAccount, - state: ParsedAccount, + proposal: ParsedAccount, + state: ParsedAccount, sigAccount: PublicKey, ) => { const PROGRAM_IDS = utils.programIds(); @@ -26,8 +30,8 @@ export const sign = async ( let instructions: TransactionInstruction[] = []; const [mintAuthority] = await PublicKey.findProgramAddress( - [proposal.pubkey.toBuffer()], - PROGRAM_IDS.timelock.programId, + [Buffer.from(GOVERNANCE_AUTHORITY_SEED), proposal.pubkey.toBuffer()], + PROGRAM_IDS.governance.programId, ); const transferAuthority = approve( diff --git a/packages/proposals/src/actions/withdrawVotingTokens.ts b/packages/governance/src/actions/withdrawVotingTokens.ts similarity index 88% rename from packages/proposals/src/actions/withdrawVotingTokens.ts rename to packages/governance/src/actions/withdrawVotingTokens.ts index d11971b..b3cf601 100644 --- a/packages/proposals/src/actions/withdrawVotingTokens.ts +++ b/packages/governance/src/actions/withdrawVotingTokens.ts @@ -13,10 +13,11 @@ import { } from '@oyster/common'; import { - TimelockSet, - TimelockState, - TimelockStateStatus, -} from '../models/timelock'; + GOVERNANCE_AUTHORITY_SEED, + Proposal, + ProposalState, + ProposalStateStatus, +} from '../models/governance'; import { AccountLayout } from '@solana/spl-token'; import { withdrawVotingTokensInstruction } from '../models/withdrawVotingTokens'; import { LABELS } from '../constants'; @@ -28,8 +29,8 @@ const { approve } = models; export const withdrawVotingTokens = async ( connection: Connection, wallet: any, - proposal: ParsedAccount, - state: ParsedAccount, + proposal: ParsedAccount, + state: ParsedAccount, existingVoteAccount: PublicKey | undefined, existingYesVoteAccount: PublicKey | undefined, existingNoVoteAccount: PublicKey | undefined, @@ -79,8 +80,8 @@ export const withdrawVotingTokens = async ( } const [mintAuthority] = await PublicKey.findProgramAddress( - [proposal.pubkey.toBuffer()], - PROGRAM_IDS.timelock.programId, + [Buffer.from(GOVERNANCE_AUTHORITY_SEED), proposal.pubkey.toBuffer()], + PROGRAM_IDS.governance.programId, ); // We dont know in this scope how much is in each account so we just ask for all in each. @@ -117,11 +118,12 @@ export const withdrawVotingTokens = async ( const [governanceVotingRecord] = await PublicKey.findProgramAddress( [ - PROGRAM_IDS.timelock.programId.toBuffer(), + Buffer.from(GOVERNANCE_AUTHORITY_SEED), + PROGRAM_IDS.governance.programId.toBuffer(), proposal.pubkey.toBuffer(), existingVoteAccount.toBuffer(), ], - PROGRAM_IDS.timelock.programId, + PROGRAM_IDS.governance.programId, ); signers.push(transferAuthority); @@ -134,8 +136,6 @@ export const withdrawVotingTokens = async ( existingNoVoteAccount, destinationAccount, proposal.info.sourceHolding, - proposal.info.yesVotingDump, - proposal.info.noVotingDump, proposal.info.votingMint, proposal.info.yesVotingMint, proposal.info.noVotingMint, @@ -148,7 +148,7 @@ export const withdrawVotingTokens = async ( ); const [msg, completedMsg] = - state.info.status === TimelockStateStatus.Voting + state.info.status === ProposalStateStatus.Voting ? [LABELS.WITHDRAWING_YOUR_VOTE, LABELS.VOTE_WITHDRAWN] : [LABELS.REFUNDING_YOUR_TOKENS, LABELS.TOKENS_REFUNDED]; diff --git a/packages/proposals/src/ant-custom.less b/packages/governance/src/ant-custom.less similarity index 100% rename from packages/proposals/src/ant-custom.less rename to packages/governance/src/ant-custom.less diff --git a/packages/proposals/src/components/Background/index.tsx b/packages/governance/src/components/Background/index.tsx similarity index 58% rename from packages/proposals/src/components/Background/index.tsx rename to packages/governance/src/components/Background/index.tsx index 4f8e737..a521e35 100644 --- a/packages/proposals/src/components/Background/index.tsx +++ b/packages/governance/src/components/Background/index.tsx @@ -1,47 +1,57 @@ -import * as CANNON from 'cannon' -import ReactDOM from 'react-dom' -import React, { useEffect, useState } from 'react' -import { Canvas } from 'react-three-fiber' -import { useCannon, Provider } from './useCannon' -import './styles.less' +import * as CANNON from 'cannon'; +import React, { useEffect, useState } from 'react'; +import { Canvas } from 'react-three-fiber'; +import { useCannon, Provider } from './useCannon'; +import './styles.less'; -function Plane({ position }: { position: any}) { +function Plane({ position }: { position: any }) { // Register plane as a physics body with zero mass const ref = useCannon({ mass: 0 }, (body: any) => { - body.addShape(new CANNON.Plane()) - body.position.set(...position) - }) + body.addShape(new CANNON.Plane()); + body.position.set(...position); + }); return ( - ) + ); } -function Box({ position }: { position: any}) { +function Box({ position }: { position: any }) { // Register box as a physics body with mass const ref = useCannon({ mass: 100000 }, (body: any) => { - body.addShape(new CANNON.Box(new CANNON.Vec3(1, 1, 1))) - body.position.set(...position) - }) + body.addShape(new CANNON.Box(new CANNON.Vec3(1, 1, 1))); + body.position.set(...position); + }); return ( - ) + ); } export const Background = () => { - const [showPlane, set] = useState(true) + const [showPlane, set] = useState(true); // When React removes (unmounts) the upper plane after 5 sec, objects should drop ... // This may seem like magic, but as the plane unmounts it removes itself from cannon and that's that - useEffect(() => void setTimeout(() => set(false), 3000), []) + useEffect(() => void setTimeout(() => set(false), 3000), []); return ( - + - + {showPlane && } @@ -54,5 +64,5 @@ export const Background = () => { {!showPlane && } - ) + ); }; diff --git a/packages/proposals/src/components/Background/styles.less b/packages/governance/src/components/Background/styles.less similarity index 100% rename from packages/proposals/src/components/Background/styles.less rename to packages/governance/src/components/Background/styles.less diff --git a/packages/proposals/src/components/Background/useCannon.tsx b/packages/governance/src/components/Background/useCannon.tsx similarity index 52% rename from packages/proposals/src/components/Background/useCannon.tsx rename to packages/governance/src/components/Background/useCannon.tsx index 1821fe6..8cab58b 100644 --- a/packages/proposals/src/components/Background/useCannon.tsx +++ b/packages/governance/src/components/Background/useCannon.tsx @@ -1,53 +1,49 @@ -import * as CANNON from 'cannon' -import React, { useState, useEffect, useContext, useRef } from 'react' -import { useFrame } from 'react-three-fiber' +import * as CANNON from 'cannon'; +import React, { useState, useEffect, useContext, useRef } from 'react'; +import { useFrame } from 'react-three-fiber'; // Cannon-world context provider -export const CannonContext = React.createContext( - null, -); +export const CannonContext = React.createContext(null); export function Provider({ children = null as any }) { // Set up physics const [world] = useState(() => new CANNON.World()); useEffect(() => { - world.broadphase = new CANNON.NaiveBroadphase() - world.solver.iterations = 10 - world.gravity.set(0, 0, -25) + world.broadphase = new CANNON.NaiveBroadphase(); + world.solver.iterations = 10; + world.gravity.set(0, 0, -25); }, [world]); // Run world stepper every frame useFrame(() => world.step(1 / 60)); // Distribute world via context - return ( - - ); + return ; } // Custom hook to maintain a world physics body export function useCannon({ ...props }, fn: any, deps = []) { - const ref = useRef() + const ref = useRef(); // Get cannon world object - const world = useContext(CannonContext) + const world = useContext(CannonContext); // Instanciate a physics body - const [body] = useState(() => new CANNON.Body(props)) + const [body] = useState(() => new CANNON.Body(props)); useEffect(() => { // Call function so the user can add shapes - fn(body) + fn(body); // Add body to world on mount - world.addBody(body) + world.addBody(body); // Remove body on unmount - return () => world.removeBody(body) - }, deps) + return () => world.removeBody(body); + }, deps); //eslint-disable-line useFrame(() => { if (ref.current) { // Transport cannon physics into the referenced threejs object - ref.current.position.copy(body.position) - ref.current.quaternion.copy(body.quaternion) + ref.current.position.copy(body.position); + ref.current.quaternion.copy(body.quaternion); } - }) + }); - return ref + return ref; } diff --git a/packages/proposals/src/components/Layout/dark-horizontal-combined-rainbow.inline.svg b/packages/governance/src/components/Layout/dark-horizontal-combined-rainbow.inline.svg similarity index 100% rename from packages/proposals/src/components/Layout/dark-horizontal-combined-rainbow.inline.svg rename to packages/governance/src/components/Layout/dark-horizontal-combined-rainbow.inline.svg diff --git a/packages/governance/src/components/Layout/index.tsx b/packages/governance/src/components/Layout/index.tsx new file mode 100644 index 0000000..f6b9baa --- /dev/null +++ b/packages/governance/src/components/Layout/index.tsx @@ -0,0 +1,60 @@ +import React from 'react'; +import './../../App.less'; +import { Layout } from 'antd'; +import { Link } from 'react-router-dom'; + +import { LABELS } from '../../constants'; +import { components } from '@oyster/common'; +import { Content, Header } from 'antd/lib/layout/layout'; +import Logo from './dark-horizontal-combined-rainbow.inline.svg'; + +const { AppBar } = components; + +export const AppLayout = React.memo((props: any) => { + // const location = useLocation(); + + // const breadcrumbNameMap: any = { + // '/governance': 'Governance', + // '/apps/1': 'Application1', + // '/apps/2': 'Application2', + // '/apps/1/detail': 'Detail', + // '/apps/2/detail': 'Detail', + // }; + + //const pathSnippets = location.pathname.split('/').filter(i => i); + // const extraBreadcrumbItems = pathSnippets.map((_, index) => { + // const url = `/${pathSnippets.slice(0, index + 1).join('/')}`; + // return ( + // + // {breadcrumbNameMap[url]} + // + // ); + // }); + + // const breadcrumbItems = [ + // + // Home + // , + // ].concat(extraBreadcrumbItems); + + // TODO: add breadcrumb + + return ( +
+ +
+
+ + {`Solana + +
+ +
+ + {/* {breadcrumbItems} */} + {props.children} + +
+
+ ); +}); diff --git a/packages/proposals/src/components/Proposal/AddSigners.tsx b/packages/governance/src/components/Proposal/AddSigners.tsx similarity index 96% rename from packages/proposals/src/components/Proposal/AddSigners.tsx rename to packages/governance/src/components/Proposal/AddSigners.tsx index fe27065..33f3f20 100644 --- a/packages/proposals/src/components/Proposal/AddSigners.tsx +++ b/packages/governance/src/components/Proposal/AddSigners.tsx @@ -1,7 +1,7 @@ import { ParsedAccount } from '@oyster/common'; import { Button, Modal, Input, Form, Progress } from 'antd'; import React, { useState } from 'react'; -import { TimelockSet, TimelockState } from '../../models/timelock'; +import { Proposal, ProposalState } from '../../models/governance'; import { utils, contexts, hooks } from '@oyster/common'; import { addSigner } from '../../actions/addSigner'; import { PublicKey } from '@solana/web3.js'; @@ -22,8 +22,8 @@ export default function AddSigners({ proposal, state, }: { - proposal: ParsedAccount; - state: ParsedAccount; + proposal: ParsedAccount; + state: ParsedAccount; }) { const wallet = useWallet(); const connection = useConnection(); diff --git a/packages/proposals/src/components/Proposal/InstructionCard.tsx b/packages/governance/src/components/Proposal/InstructionCard.tsx similarity index 70% rename from packages/proposals/src/components/Proposal/InstructionCard.tsx rename to packages/governance/src/components/Proposal/InstructionCard.tsx index 7de76cf..a1c4f80 100644 --- a/packages/proposals/src/components/Proposal/InstructionCard.tsx +++ b/packages/governance/src/components/Proposal/InstructionCard.tsx @@ -7,17 +7,19 @@ import { RedoOutlined, } from '@ant-design/icons'; import { ParsedAccount, contexts } from '@oyster/common'; -import { Card } from 'antd'; +import { Message } from '@solana/web3.js'; +import { Card, Button } from 'antd'; import Meta from 'antd/lib/card/Meta'; -import React, { useEffect, useState } from 'react'; +import React, { useEffect, useMemo, useState } from 'react'; import { execute } from '../../actions/execute'; import { LABELS } from '../../constants'; import { - TimelockSet, - TimelockState, - TimelockStateStatus, - TimelockTransaction, -} from '../../models/timelock'; + Proposal, + ProposalState, + ProposalStateStatus, + GovernanceTransaction, +} from '../../models/governance'; + import './style.less'; const { useWallet } = contexts.Wallet; @@ -35,22 +37,33 @@ export function InstructionCard({ state, position, }: { - instruction: ParsedAccount; - proposal: ParsedAccount; - state: ParsedAccount; + instruction: ParsedAccount; + proposal: ParsedAccount; + state: ParsedAccount; position: number; }) { const [tabKey, setTabKey] = useState('info'); const [playing, setPlaying] = useState( instruction.info.executed === 1 ? Playstate.Played : Playstate.Unplayed, ); + + const instructionDetails = useMemo(() => { + const message = Message.from(instruction.info.instruction); + + return { + instructionProgramID: + message.accountKeys[message.instructions[0].programIdIndex], + instructionData: message.instructions[0].data, + }; + }, [instruction]); + const contentList: Record = { info: ( -

Instruction: TODO

+

{`${LABELS.INSTRUCTION}: ${instructionDetails.instructionData}`}

{LABELS.DELAY}: {instruction.info.slot.toNumber()}

@@ -93,9 +106,9 @@ function PlayStatusButton({ setPlaying, instruction, }: { - proposal: ParsedAccount; - state: ParsedAccount; - instruction: ParsedAccount; + proposal: ParsedAccount; + state: ParsedAccount; + instruction: ParsedAccount; playing: Playstate; setPlaying: React.Dispatch>; }) { @@ -108,9 +121,13 @@ function PlayStatusButton({ useEffect(() => { if (ineligibleToSee) { - const id = setTimeout(() => { + const timer = setTimeout(() => { connection.getSlot().then(setCurrSlot); }, 5000); + + return () => { + clearTimeout(timer); + }; } }, [ineligibleToSee, connection, currSlot]); @@ -127,25 +144,25 @@ function PlayStatusButton({ }; if ( - state.info.status != TimelockStateStatus.Executing && - state.info.status != TimelockStateStatus.Completed + state.info.status !== ProposalStateStatus.Executing && + state.info.status !== ProposalStateStatus.Completed ) return null; if (ineligibleToSee) return null; if (playing === Playstate.Unplayed) return ( - + ); else if (playing === Playstate.Playing) return ; else if (playing === Playstate.Error) return ( - + ); else return ; } diff --git a/packages/proposals/src/components/Proposal/MintSourceTokens.tsx b/packages/governance/src/components/Proposal/MintSourceTokens.tsx similarity index 95% rename from packages/proposals/src/components/Proposal/MintSourceTokens.tsx rename to packages/governance/src/components/Proposal/MintSourceTokens.tsx index 2ae65fd..291f1d6 100644 --- a/packages/proposals/src/components/Proposal/MintSourceTokens.tsx +++ b/packages/governance/src/components/Proposal/MintSourceTokens.tsx @@ -1,7 +1,7 @@ import { ParsedAccount } from '@oyster/common'; import { Button, Modal, Input, Form, Progress, InputNumber, Radio } from 'antd'; import React, { useState } from 'react'; -import { TimelockConfig } from '../../models/timelock'; +import { Governance } from '../../models/governance'; import { utils, contexts } from '@oyster/common'; import { PublicKey } from '@solana/web3.js'; import { LABELS } from '../../constants'; @@ -22,18 +22,18 @@ const layout = { }; export default function MintSourceTokens({ - timelockConfig, + governance, useGovernance, }: { - timelockConfig: ParsedAccount; + governance: ParsedAccount; useGovernance: boolean; }) { const PROGRAM_IDS = utils.programIds(); const wallet = useWallet(); const connection = useConnection(); const mintKey = useGovernance - ? timelockConfig.info.governanceMint - : timelockConfig.info.councilMint; + ? governance.info.governanceMint + : governance.info.councilMint!; const mint = useMint(mintKey); const [saving, setSaving] = useState(false); @@ -57,7 +57,7 @@ export default function MintSourceTokens({ let failedSourcesHold: SourceEntryInterface[] = []; const zeroKey = PROGRAM_IDS.system; sourceHoldersAndCounts.forEach((value: string, index: number) => { - if (index % 2 == 0) + if (index % 2 === 0) sourceHolders.push({ owner: value ? new PublicKey(value) : zeroKey, tokenAmount: 0, @@ -66,7 +66,7 @@ export default function MintSourceTokens({ else sourceHolders[sourceHolders.length - 1].tokenAmount = parseInt(value); }); - console.log(sourceHolders); + //console.log(sourceHolders); if (singleSourceHolder) sourceHolders.push({ @@ -75,7 +75,7 @@ export default function MintSourceTokens({ sourceAccount: undefined, }); - if (!sourceHolders.find(v => v.owner != zeroKey)) { + if (!sourceHolders.find(v => v.owner !== zeroKey)) { notify({ message: LABELS.ENTER_AT_LEAST_ONE_PUB_KEY, type: 'error', @@ -108,7 +108,7 @@ export default function MintSourceTokens({ try { if (sourceHolders[i].owner) { const tokenAccounts = await connection.getTokenAccountsByOwner( - sourceHolders[i].owner || PROGRAM_IDS.timelock, + sourceHolders[i].owner || PROGRAM_IDS.governance, { programId: PROGRAM_IDS.token, }, @@ -130,7 +130,7 @@ export default function MintSourceTokens({ await mintSourceTokens( connection, wallet.wallet, - timelockConfig, + governance, useGovernance, sourceHoldersToRun, setSavePerc, diff --git a/packages/proposals/src/components/Proposal/NewInstructionCard.tsx b/packages/governance/src/components/Proposal/NewInstructionCard.tsx similarity index 92% rename from packages/proposals/src/components/Proposal/NewInstructionCard.tsx rename to packages/governance/src/components/Proposal/NewInstructionCard.tsx index af8fc55..f57d238 100644 --- a/packages/proposals/src/components/Proposal/NewInstructionCard.tsx +++ b/packages/governance/src/components/Proposal/NewInstructionCard.tsx @@ -3,10 +3,10 @@ import { Card } from 'antd'; import { Form, Input } from 'antd'; import { INSTRUCTION_LIMIT, - TimelockConfig, - TimelockSet, - TimelockState, -} from '../../models/timelock'; + Governance, + Proposal, + ProposalState, +} from '../../models/governance'; import { contexts, ParsedAccount, hooks, utils } from '@oyster/common'; import { addCustomSingleSignerTransaction } from '../../actions/addCustomSingleSignerTransaction'; import { SaveOutlined } from '@ant-design/icons'; @@ -28,9 +28,9 @@ export function NewInstructionCard({ position, config, }: { - proposal: ParsedAccount; - state: ParsedAccount; - config: ParsedAccount; + proposal: ParsedAccount; + state: ParsedAccount; + config: ParsedAccount; position: number; }) { const [form] = Form.useForm(); diff --git a/packages/proposals/src/components/Proposal/SignButton.tsx b/packages/governance/src/components/Proposal/SignButton.tsx similarity index 92% rename from packages/proposals/src/components/Proposal/SignButton.tsx rename to packages/governance/src/components/Proposal/SignButton.tsx index 0e9ba8d..2d74b84 100644 --- a/packages/proposals/src/components/Proposal/SignButton.tsx +++ b/packages/governance/src/components/Proposal/SignButton.tsx @@ -3,7 +3,7 @@ import { ParsedAccount, hooks, contexts, utils } from '@oyster/common'; import { Button, Modal } from 'antd'; import React from 'react'; import { sign } from '../../actions/sign'; -import { TimelockSet, TimelockState } from '../../models/timelock'; +import { Proposal, ProposalState } from '../../models/governance'; const { confirm } = Modal; const { useWallet } = contexts.Wallet; @@ -15,8 +15,8 @@ export default function SignButton({ proposal, state, }: { - proposal: ParsedAccount; - state: ParsedAccount; + proposal: ParsedAccount; + state: ParsedAccount; }) { const wallet = useWallet(); const connection = useConnection(); diff --git a/packages/proposals/src/components/Proposal/StateBadge.tsx b/packages/governance/src/components/Proposal/StateBadge.tsx similarity index 67% rename from packages/proposals/src/components/Proposal/StateBadge.tsx rename to packages/governance/src/components/Proposal/StateBadge.tsx index 16098eb..9666210 100644 --- a/packages/proposals/src/components/Proposal/StateBadge.tsx +++ b/packages/governance/src/components/Proposal/StateBadge.tsx @@ -3,15 +3,15 @@ import { Badge, Tag } from 'antd'; import React from 'react'; import { STATE_COLOR, - TimelockState, - TimelockStateStatus, -} from '../../models/timelock'; + ProposalState, + ProposalStateStatus, +} from '../../models/governance'; export function StateBadgeRibbon({ state, children, }: { - state: ParsedAccount; + state: ParsedAccount; children?: any; }) { const status = state.info.status; @@ -19,19 +19,19 @@ export function StateBadgeRibbon({ return ( {children} ); } -export function StateBadge({ state }: { state: ParsedAccount }) { +export function StateBadge({ state }: { state: ParsedAccount }) { const status = state.info.status; let color = STATE_COLOR[status]; return ( - {TimelockStateStatus[status]} + {ProposalStateStatus[status]} ); } diff --git a/packages/proposals/src/components/Proposal/Vote.tsx b/packages/governance/src/components/Proposal/Vote.tsx similarity index 88% rename from packages/proposals/src/components/Proposal/Vote.tsx rename to packages/governance/src/components/Proposal/Vote.tsx index 630eb0e..76806cd 100644 --- a/packages/proposals/src/components/Proposal/Vote.tsx +++ b/packages/governance/src/components/Proposal/Vote.tsx @@ -2,11 +2,11 @@ import { ParsedAccount } from '@oyster/common'; import { Button, Col, Modal, Row } from 'antd'; import React from 'react'; import { - TimelockConfig, - TimelockSet, - TimelockState, - TimelockStateStatus, -} from '../../models/timelock'; + Governance, + Proposal, + ProposalState, + ProposalStateStatus, +} from '../../models/governance'; import { LABELS } from '../../constants'; import { depositSourceTokensAndVote } from '../../actions/depositSourceTokensAndVote'; import { contexts, hooks } from '@oyster/common'; @@ -22,12 +22,12 @@ const { confirm } = Modal; export function Vote({ proposal, state, - timelockConfig, + governance, yeahVote, }: { - proposal: ParsedAccount; - state: ParsedAccount; - timelockConfig: ParsedAccount; + proposal: ParsedAccount; + state: ParsedAccount; + governance: ParsedAccount; yeahVote: boolean; }) { const wallet = useWallet(); @@ -42,7 +42,7 @@ export function Vote({ const eligibleToView = userTokenAccount && userTokenAccount.info.amount.toNumber() > 0 && - state.info.status === TimelockStateStatus.Voting; + state.info.status === ProposalStateStatus.Voting; const [btnLabel, title, msg, icon] = yeahVote ? [ @@ -90,7 +90,7 @@ export function Vote({ yesVoteAccount?.pubkey, noVoteAccount?.pubkey, userTokenAccount.pubkey, - timelockConfig, + governance, state, yesTokenAmount, noTokenAmount, diff --git a/packages/proposals/src/components/Proposal/VoterBubbleGraph.tsx b/packages/governance/src/components/Proposal/VoterBubbleGraph.tsx similarity index 80% rename from packages/proposals/src/components/Proposal/VoterBubbleGraph.tsx rename to packages/governance/src/components/Proposal/VoterBubbleGraph.tsx index ead3c78..4dc236e 100644 --- a/packages/proposals/src/components/Proposal/VoterBubbleGraph.tsx +++ b/packages/governance/src/components/Proposal/VoterBubbleGraph.tsx @@ -14,10 +14,6 @@ const MAX_BUBBLE_AMOUNT = 50; export function VoterBubbleGraph(props: IVoterBubbleGraph) { const { data, width, height, endpoint } = props; - const subdomain = endpoint - .replace('http://', '') - .replace('https://', '') - .split('.')[0]; // For some reason giving this a type causes an issue where setRef // cant be used with ref={} prop...not sure why. SetStateAction nonsense. @@ -30,28 +26,34 @@ export function VoterBubbleGraph(props: IVoterBubbleGraph) { '...' + d.name.slice(d.name.length - 3, d.name.length), })); - console.log('Data', limitedData); - const format = d3.format(',d'); - const color = d3 - .scaleOrdinal() - .domain([VoteType.Undecided, VoteType.Yes, VoteType.No]) - .range(['grey', 'green', 'red']); - - const pack = (data: Array) => { - return d3 - .pack() - .size([width - 2, height - 2]) - .padding(3)( - //@ts-ignore - d3.hierarchy({ children: data }).sum(d => (d.value ? d.value : 0)), - ); - }; + //console.log('Data', limitedData); useEffect(() => { if (ref) { + const subdomain = endpoint + .replace('http://', '') + .replace('https://', '') + .split('.')[0]; + + const format = d3.format(',d'); + const color = d3 + .scaleOrdinal() + .domain([VoteType.Undecided, VoteType.Yes, VoteType.No]) + .range(['grey', 'green', 'red']); + + const pack = (data: Array) => { + return d3 + .pack() + .size([width - 2, height - 2]) + .padding(3)( + //@ts-ignore + d3.hierarchy({ children: data }).sum(d => (d.value ? d.value : 0)), + ); + }; + ref.innerHTML = ''; const root = pack(limitedData); - console.log('Re-rendered'); + // console.log('Re-rendered'); const newSvg = d3 .select(ref) .append('svg') @@ -127,7 +129,7 @@ export function VoterBubbleGraph(props: IVoterBubbleGraph) { }${format(d.value)}`, ); } - }, [ref, limitedData, height, width]); + }, [ref, limitedData, height, width, endpoint]); return (
{ {breakpoint.xxl && ( @@ -89,7 +90,7 @@ export const VoterTable = (props: IVoterTable) => { render: (count: number, record: VoterDisplayData) => ( { { title: LABELS.PERCENTAGE, dataIndex: 'value', - key: 'value', + key: 'percentage', align: 'center', render: (count: number, record: VoterDisplayData) => ( ; - state: ParsedAccount; - timelockConfig: ParsedAccount; + proposal: ParsedAccount; + state: ParsedAccount; }) { const wallet = useWallet(); const connection = useConnection(); @@ -41,13 +39,13 @@ export function WithdrawVote({ const eligibleToView = votingTokens > 0 && - (state.info.status === TimelockStateStatus.Voting || - state.info.status === TimelockStateStatus.Completed || - state.info.status === TimelockStateStatus.Executing || - state.info.status === TimelockStateStatus.Defeated); + (state.info.status === ProposalStateStatus.Voting || + state.info.status === ProposalStateStatus.Completed || + state.info.status === ProposalStateStatus.Executing || + state.info.status === ProposalStateStatus.Defeated); const [btnLabel, title, msg, action] = - state.info.status === TimelockStateStatus.Voting + state.info.status === ProposalStateStatus.Voting ? [ LABELS.WITHDRAW_VOTE, LABELS.WITHDRAW_YOUR_VOTE_QUESTION, diff --git a/packages/proposals/src/components/Proposal/style.less b/packages/governance/src/components/Proposal/style.less similarity index 100% rename from packages/proposals/src/components/Proposal/style.less rename to packages/governance/src/components/Proposal/style.less diff --git a/packages/proposals/src/constants/index.tsx b/packages/governance/src/constants/index.tsx similarity index 100% rename from packages/proposals/src/constants/index.tsx rename to packages/governance/src/constants/index.tsx diff --git a/packages/proposals/src/constants/labels.ts b/packages/governance/src/constants/labels.ts similarity index 96% rename from packages/proposals/src/constants/labels.ts rename to packages/governance/src/constants/labels.ts index 34a1902..a2de71d 100644 --- a/packages/proposals/src/constants/labels.ts +++ b/packages/governance/src/constants/labels.ts @@ -99,19 +99,21 @@ export const LABELS = { TOKENS_REFUNDED: 'Your voting tokens have been refunded', REGISTER_GOVERNANCE: 'Register', - PROGRAM: 'Program ID', + + PROGRAM_ID: 'Program ID', + INSTRUCTION: 'Instruction', + GOVERNANCE: 'Governance Token Holders', COUNCIL: 'The Council', GOVERNANCE_MINT: 'Governance Mint ID', USE_COUNCIL_MINT: 'Allow Council Mint?', COUNCIL_MINT: 'Council Mint ID', - PROPOSAL_TYPE: 'Proposal Type', - EXECUTION_TYPE: 'Execution Type', - CONSENSUS_ALGORITHM: 'Consensus Algorithm', - VOTING_ENTRY_RULES: 'Voting Entry Rules', + + VOTE_PERCENT_THRESHOLD: 'Vote Threshold (%)', + SELECT_PROPOSAL_TYPE: 'Select the type of proposals this app will generate', SELECT_EXECUTION_TYPE: 'Select how transactions will be executed', - SELECT_CONSENSUS_ALGORITHM: 'Select the consensus algorithm', + SELECT_VOTING_ENTRY_RULE: 'Select the rules for registering to vote in proposals', MINIMUM_SLOT_WAITING_PERIOD: 'Minimum slots between proposal and vote', diff --git a/packages/proposals/src/constants/style.tsx b/packages/governance/src/constants/style.tsx similarity index 100% rename from packages/proposals/src/constants/style.tsx rename to packages/governance/src/constants/style.tsx diff --git a/packages/proposals/src/contexts/proposals.tsx b/packages/governance/src/contexts/proposals.tsx similarity index 55% rename from packages/proposals/src/contexts/proposals.tsx rename to packages/governance/src/contexts/proposals.tsx index badf957..b5920e0 100644 --- a/packages/proposals/src/contexts/proposals.tsx +++ b/packages/governance/src/contexts/proposals.tsx @@ -3,6 +3,7 @@ import React, { useContext, useEffect, useState } from 'react'; import { Connection, KeyedAccountInfo, + PublicKey, PublicKeyAndAccount, } from '@solana/web3.js'; import { useMemo } from 'react'; @@ -14,26 +15,26 @@ import { cache, } from '@oyster/common'; import { - CustomSingleSignerTimelockTransactionLayout, - CustomSingleSignerTimelockTransactionParser, - TimelockConfig, - TimelockConfigLayout, - TimelockConfigParser, - TimelockSet, - TimelockState, - TimelockSetLayout, - TimelockSetParser, - TimelockTransaction, - TimelockStateParser, - TimelockStateLayout, - CustomSingleSignerTimelockTransaction, -} from '../models/timelock'; + CustomSingleSignerTransactionLayout, + CustomSingleSignerTransactionParser, + Governance, + GovernanceLayout, + GovernanceParser, + Proposal, + ProposalState, + ProposalLayout, + ProposalParser, + GovernanceTransaction, + ProposalStateParser, + ProposalStateLayout, + CustomSingleSignerTransaction, +} from '../models/governance'; export interface ProposalsContextState { - proposals: Record>; - transactions: Record>; - states: Record>; - configs: Record>; + proposals: Record>; + transactions: Record>; + states: Record>; + configs: Record>; } export const ProposalsContext = React.createContext( @@ -81,49 +82,47 @@ function useSetupProposalsCache({ setStates: React.Dispatch>; setConfigs: React.Dispatch>; }) { - const PROGRAM_IDS = utils.programIds(); - useEffect(() => { + const PROGRAM_IDS = utils.programIds(); + const query = async () => { const programAccounts = await connection.getProgramAccounts( - PROGRAM_IDS.timelock.programId, + PROGRAM_IDS.governance.programId, ); return programAccounts; }; Promise.all([query()]).then((all: PublicKeyAndAccount[][]) => { - const newProposals: Record> = {}; + const newProposals: Record> = {}; const newTransactions: Record< string, - ParsedAccount + ParsedAccount > = {}; - const newStates: Record> = {}; - const newConfigs: Record> = {}; + const newStates: Record> = {}; + const newConfigs: Record> = {}; all[0].forEach(a => { let cached; switch (a.account.data.length) { - case TimelockSetLayout.span: - cache.add(a.pubkey, a.account, TimelockSetParser); - cached = cache.get(a.pubkey) as ParsedAccount; + case ProposalLayout.span: + cache.add(a.pubkey, a.account, ProposalParser); + cached = cache.get(a.pubkey) as ParsedAccount; newProposals[a.pubkey.toBase58()] = cached; break; - case CustomSingleSignerTimelockTransactionLayout.span: - cache.add( + case CustomSingleSignerTransactionLayout.span: + cache.add(a.pubkey, a.account, CustomSingleSignerTransactionParser); + cached = cache.get( a.pubkey, - a.account, - CustomSingleSignerTimelockTransactionParser, - ); - cached = cache.get(a.pubkey) as ParsedAccount; + ) as ParsedAccount; newTransactions[a.pubkey.toBase58()] = cached; break; - case TimelockConfigLayout.span: - cache.add(a.pubkey, a.account, TimelockConfigParser); - cached = cache.get(a.pubkey) as ParsedAccount; + case GovernanceLayout.span: + cache.add(a.pubkey, a.account, GovernanceParser); + cached = cache.get(a.pubkey) as ParsedAccount; newConfigs[a.pubkey.toBase58()] = cached; break; - case TimelockStateLayout.span: - cache.add(a.pubkey, a.account, TimelockStateParser); - cached = cache.get(a.pubkey) as ParsedAccount; + case ProposalStateLayout.span: + cache.add(a.pubkey, a.account, ProposalStateParser); + cached = cache.get(a.pubkey) as ParsedAccount; newStates[a.pubkey.toBase58()] = cached; break; } @@ -135,49 +134,47 @@ function useSetupProposalsCache({ setConfigs(newConfigs); }); const subID = connection.onProgramAccountChange( - PROGRAM_IDS.timelock.programId, + PROGRAM_IDS.governance.programId, async (info: KeyedAccountInfo) => { + const pubkey = typeof info.accountId === 'string' ? + new PublicKey((info.accountId as unknown) as string) : + info.accountId; + [ - [TimelockSetLayout.span, TimelockSetParser, setProposals], + [ProposalLayout.span, ProposalParser, setProposals], [ - CustomSingleSignerTimelockTransactionLayout.span, - CustomSingleSignerTimelockTransactionParser, + CustomSingleSignerTransactionLayout.span, + CustomSingleSignerTransactionParser, setTransactions, ], - [TimelockStateLayout.span, TimelockStateParser, setStates], - [TimelockConfigLayout.span, TimelockConfigParser, setConfigs], + [ProposalStateLayout.span, ProposalStateParser, setStates], + [GovernanceLayout.span, GovernanceParser, setConfigs], ].forEach(arr => { const [span, parser, setter] = arr; if (info.accountInfo.data.length === span) { cache.add(info.accountId, info.accountInfo, parser); let cached: any; switch (info.accountInfo.data.length) { - case TimelockSetLayout.span: - cached = cache.get( - info.accountId, - ) as ParsedAccount; + case ProposalLayout.span: + cached = cache.get(info.accountId) as ParsedAccount; break; - case CustomSingleSignerTimelockTransactionLayout.span: + case CustomSingleSignerTransactionLayout.span: cached = cache.get( info.accountId, - ) as ParsedAccount; + ) as ParsedAccount; break; - case TimelockConfigLayout.span: - cached = cache.get( - info.accountId, - ) as ParsedAccount; + case GovernanceLayout.span: + cached = cache.get(info.accountId) as ParsedAccount; break; - case TimelockStateLayout.span: + case ProposalStateLayout.span: cached = cache.get( info.accountId, - ) as ParsedAccount; + ) as ParsedAccount; break; } setter((obj: any) => ({ ...obj, - [typeof info.accountId === 'string' - ? info.accountId - : info.accountId.toBase58()]: cached, + [pubkey.toBase58()]: cached, })); } }); @@ -187,7 +184,7 @@ function useSetupProposalsCache({ return () => { connection.removeProgramAccountChangeListener(subID); }; - }, [connection, PROGRAM_IDS.timelock.programId.toBase58()]); + }, [connection]); //eslint-disable-line } export const useProposals = () => { const context = useContext(ProposalsContext); diff --git a/packages/proposals/src/hooks/useVotingRecords.ts b/packages/governance/src/hooks/useVotingRecords.ts similarity index 88% rename from packages/proposals/src/hooks/useVotingRecords.ts rename to packages/governance/src/hooks/useVotingRecords.ts index 6581a2d..23c64ed 100644 --- a/packages/proposals/src/hooks/useVotingRecords.ts +++ b/packages/governance/src/hooks/useVotingRecords.ts @@ -11,7 +11,7 @@ import { GovernanceVotingRecord, GovernanceVotingRecordLayout, GovernanceVotingRecordParser, -} from '../models/timelock'; +} from '../models/governance'; import { getGovernanceVotingRecords } from '../utils/lookups'; export function useVotingRecords(proposal: PublicKey) { @@ -22,8 +22,6 @@ export function useVotingRecords(proposal: PublicKey) { const { endpoint } = useConnectionConfig(); const connection = useConnection(); - const { timelock } = utils.programIds(); - useEffect(() => { if (!proposal) { return; @@ -33,7 +31,9 @@ export function useVotingRecords(proposal: PublicKey) { const records = await getGovernanceVotingRecords(proposal, endpoint); setVotingRecords(records); - return connection.onProgramAccountChange(timelock.programId, info => { + const { governance } = utils.programIds(); + + return connection.onProgramAccountChange(governance.programId, info => { if ( info.accountInfo.data.length === GovernanceVotingRecordLayout.span ) { @@ -57,7 +57,7 @@ export function useVotingRecords(proposal: PublicKey) { return () => { sub.then(id => connection.removeProgramAccountChangeListener(id)); }; - }, [proposal]); + }, [proposal, connection, endpoint]); return votingRecords; } diff --git a/packages/proposals/src/index.tsx b/packages/governance/src/index.tsx similarity index 100% rename from packages/proposals/src/index.tsx rename to packages/governance/src/index.tsx diff --git a/packages/proposals/src/manifest.json b/packages/governance/src/manifest.json similarity index 84% rename from packages/proposals/src/manifest.json rename to packages/governance/src/manifest.json index adc115d..87bc3cd 100644 --- a/packages/proposals/src/manifest.json +++ b/packages/governance/src/manifest.json @@ -1,6 +1,6 @@ { - "name": "Oyster Proposals", - "short_name": "Oyster Proposals", + "name": "Oyster Governance", + "short_name": "Oyster Governance", "display": "standalone", "start_url": "./", "theme_color": "#002140", diff --git a/packages/proposals/src/models/addCustomSingleSignerTransaction.ts b/packages/governance/src/models/addCustomSingleSignerTransaction.ts similarity index 70% rename from packages/proposals/src/models/addCustomSingleSignerTransaction.ts rename to packages/governance/src/models/addCustomSingleSignerTransaction.ts index e15890f..b75c125 100644 --- a/packages/proposals/src/models/addCustomSingleSignerTransaction.ts +++ b/packages/governance/src/models/addCustomSingleSignerTransaction.ts @@ -5,32 +5,32 @@ import * as Layout from '../utils/layout'; import * as BufferLayout from 'buffer-layout'; import { INSTRUCTION_LIMIT, - TimelockInstruction, - TRANSACTION_SLOTS, -} from './timelock'; + GovernanceInstruction, + MAX_TRANSACTIONS, +} from './governance'; import BN from 'bn.js'; /// [Requires Signatory token] -/// Adds a Transaction to the Timelock Set. Max of 10 of any Transaction type. More than 10 will throw error. +/// Adds a Transaction to the Proposal. Max of 10 of any Transaction type. More than 10 will throw error. /// Creates a PDA using your authority to be used to later execute the instruction. /// This transaction needs to contain authority to execute the program. /// -/// 0. `[writable]` Uninitialized Timelock Transaction account. -/// 1. `[writable]` Timelock set account. +/// 0. `[writable]` Uninitialized Proposal Transaction account. +/// 1. `[writable]` Proposal account. /// 2. `[writable]` Signatory account /// 3. `[writable]` Signatory validation account. -/// 4. `[]` Timelock Set account. -/// 5. `[]` Timelock Config account. +/// 4. `[]` Proposal account. +/// 5. `[]` Governance account. /// 6. `[]` Transfer authority -/// 7. `[]` Timelock mint authority +/// 7. `[]` Governance mint authority /// 8. `[]` Token program account. export const addCustomSingleSignerTransactionInstruction = ( - timelockTransactionAccount: PublicKey, - timelockStateAccount: PublicKey, + proposalTransactionAccount: PublicKey, + proposalStateAccount: PublicKey, signatoryAccount: PublicKey, signatoryValidationAccount: PublicKey, - timelockSetAccount: PublicKey, - timelockConfigAccount: PublicKey, + proposalAccount: PublicKey, + governanceAccount: PublicKey, transferAuthority: PublicKey, authority: PublicKey, slot: string, @@ -53,9 +53,9 @@ export const addCustomSingleSignerTransactionInstruction = ( ); } - if (position > TRANSACTION_SLOTS) { + if (position > MAX_TRANSACTIONS) { throw new Error( - 'Position is more than ' + TRANSACTION_SLOTS + ' which is not allowed.', + 'Position is more than ' + MAX_TRANSACTIONS + ' which is not allowed.', ); } @@ -75,7 +75,7 @@ export const addCustomSingleSignerTransactionInstruction = ( dataLayout.encode( { - instruction: TimelockInstruction.AddCustomSingleSignerTransaction, + instruction: GovernanceInstruction.AddCustomSingleSignerTransaction, slot: new BN(slot), instructions: instructionAsBytes, position: position, @@ -85,12 +85,12 @@ export const addCustomSingleSignerTransactionInstruction = ( ); const keys = [ - { pubkey: timelockTransactionAccount, isSigner: true, isWritable: true }, - { pubkey: timelockStateAccount, isSigner: false, isWritable: true }, + { pubkey: proposalTransactionAccount, isSigner: true, isWritable: true }, + { pubkey: proposalStateAccount, isSigner: false, isWritable: true }, { pubkey: signatoryAccount, isSigner: false, isWritable: true }, { pubkey: signatoryValidationAccount, isSigner: false, isWritable: true }, - { pubkey: timelockSetAccount, isSigner: false, isWritable: false }, - { pubkey: timelockConfigAccount, isSigner: false, isWritable: false }, + { pubkey: proposalAccount, isSigner: false, isWritable: false }, + { pubkey: governanceAccount, isSigner: false, isWritable: false }, { pubkey: transferAuthority, isSigner: true, isWritable: false }, { pubkey: authority, isSigner: false, isWritable: false }, { pubkey: PROGRAM_IDS.token, isSigner: false, isWritable: false }, @@ -98,7 +98,7 @@ export const addCustomSingleSignerTransactionInstruction = ( return new TransactionInstruction({ keys, - programId: PROGRAM_IDS.timelock.programId, + programId: PROGRAM_IDS.governance.programId, data, }); }; diff --git a/packages/proposals/src/models/addSigner.ts b/packages/governance/src/models/addSigner.ts similarity index 73% rename from packages/proposals/src/models/addSigner.ts rename to packages/governance/src/models/addSigner.ts index 244354e..e785c8d 100644 --- a/packages/proposals/src/models/addSigner.ts +++ b/packages/governance/src/models/addSigner.ts @@ -1,10 +1,10 @@ import { PublicKey, TransactionInstruction } from '@solana/web3.js'; import { utils } from '@oyster/common'; import * as BufferLayout from 'buffer-layout'; -import { TimelockInstruction } from './timelock'; +import { GovernanceInstruction } from './governance'; /// [Requires Admin token] -/// Adds a signatory to the Timelock which means that this timelock can't leave Draft state until yet another signatory burns +/// Adds a signatory to the Proposal which means that this Proposal can't leave Draft state until yet another signatory burns /// their signatory token indicating they are satisfied with the instruction queue. They'll receive an signatory token /// as a result of this call that they can burn later. /// @@ -12,18 +12,18 @@ import { TimelockInstruction } from './timelock'; /// 1. `[writable]` Initialized Signatory mint account. /// 2. `[writable]` Admin account. /// 3. `[writable]` Admin validation account. -/// 4. `[writable]` Timelock set account. -/// 5. `[]` Timelock set account. +/// 4. `[writable]` Proposal account. +/// 5. `[]` Proposal account. /// 6. `[]` Transfer authority -/// 7. `[]` Timelock program mint authority +/// 7. `[]` Governance program mint authority /// 8. '[]` Token program id. export const addSignerInstruction = ( signatoryAccount: PublicKey, signatoryMintAccount: PublicKey, adminAccount: PublicKey, adminValidationAccount: PublicKey, - timelockStateAccount: PublicKey, - timelockSetAccount: PublicKey, + proposalStateAccount: PublicKey, + proposalAccount: PublicKey, transferAuthority: PublicKey, mintAuthority: PublicKey, ): TransactionInstruction => { @@ -35,7 +35,7 @@ export const addSignerInstruction = ( dataLayout.encode( { - instruction: TimelockInstruction.AddSigner, + instruction: GovernanceInstruction.AddSigner, }, data, ); @@ -45,15 +45,15 @@ export const addSignerInstruction = ( { pubkey: signatoryMintAccount, isSigner: false, isWritable: true }, { pubkey: adminAccount, isSigner: false, isWritable: true }, { pubkey: adminValidationAccount, isSigner: false, isWritable: true }, - { pubkey: timelockStateAccount, isSigner: false, isWritable: true }, - { pubkey: timelockSetAccount, isSigner: false, isWritable: false }, + { pubkey: proposalStateAccount, isSigner: false, isWritable: true }, + { pubkey: proposalAccount, isSigner: false, isWritable: false }, { pubkey: transferAuthority, isSigner: true, isWritable: false }, { pubkey: mintAuthority, isSigner: false, isWritable: false }, { pubkey: PROGRAM_IDS.token, isSigner: false, isWritable: false }, ]; return new TransactionInstruction({ keys, - programId: PROGRAM_IDS.timelock.programId, + programId: PROGRAM_IDS.governance.programId, data, }); }; diff --git a/packages/proposals/src/models/createEmptyGovernanceVotingRecord.ts b/packages/governance/src/models/createEmptyGovernanceVotingRecord.ts similarity index 80% rename from packages/proposals/src/models/createEmptyGovernanceVotingRecord.ts rename to packages/governance/src/models/createEmptyGovernanceVotingRecord.ts index 9326817..8814672 100644 --- a/packages/proposals/src/models/createEmptyGovernanceVotingRecord.ts +++ b/packages/governance/src/models/createEmptyGovernanceVotingRecord.ts @@ -1,14 +1,14 @@ import { PublicKey, TransactionInstruction } from '@solana/web3.js'; import { utils } from '@oyster/common'; import * as BufferLayout from 'buffer-layout'; -import { TimelockInstruction } from './timelock'; +import { GovernanceInstruction } from './governance'; /// 0. `[]` Governance voting record key. Needs to be set with pubkey set to PDA with seeds of the /// program account key, proposal key, your voting account key. /// 1. `[]` Proposal key /// 2. `[]` Your voting account /// 3. `[]` Payer -/// 4. `[]` Timelock program pub key. +/// 4. `[]` Governance program pub key /// 5. `[]` System account. export const createEmptyGovernanceVotingRecordInstruction = ( governanceRecordAccount: PublicKey, @@ -24,7 +24,7 @@ export const createEmptyGovernanceVotingRecordInstruction = ( dataLayout.encode( { - instruction: TimelockInstruction.CreateGovernanceVotingRecord, + instruction: GovernanceInstruction.CreateGovernanceVotingRecord, }, data, ); @@ -34,16 +34,12 @@ export const createEmptyGovernanceVotingRecordInstruction = ( { pubkey: proposalAccount, isSigner: false, isWritable: false }, { pubkey: votingAccount, isSigner: false, isWritable: false }, { pubkey: payer, isSigner: true, isWritable: false }, - { - pubkey: PROGRAM_IDS.timelock.programId, - isSigner: false, - isWritable: false, - }, + { pubkey: PROGRAM_IDS.system, isSigner: false, isWritable: false }, ]; return new TransactionInstruction({ keys, - programId: PROGRAM_IDS.timelock.programId, + programId: PROGRAM_IDS.governance.programId, data, }); }; diff --git a/packages/governance/src/models/createGovernance.ts b/packages/governance/src/models/createGovernance.ts new file mode 100644 index 0000000..51b8c3a --- /dev/null +++ b/packages/governance/src/models/createGovernance.ts @@ -0,0 +1,91 @@ +import { PublicKey, TransactionInstruction } from '@solana/web3.js'; +import { utils } from '@oyster/common'; +import * as BufferLayout from 'buffer-layout'; +import { GOVERNANCE_NAME_LENGTH, GovernanceInstruction } from './governance'; +import BN from 'bn.js'; +import * as Layout from '../utils/layout'; + +/// 0. `[writable]` Governance account. The account pubkey needs to be set to PDA with the following seeds: +/// 1) 'governance' const prefix, 2) Governed Program account key +/// 1. `[]` Account of the Program governed by this Governance account +/// 2. `[writable]` Program Data account of the Program governed by this Governance account +/// 3. `[signer]` Current Upgrade Authority account of the Program governed by this Governance account +/// 4. `[]` Governance mint that this Governance uses +/// 5. `[signer]` Payer +/// 6. `[]` System account. +/// 7. `[]` bpf_upgrade_loader account. +/// 8. `[]` Council mint that this Governance uses [Optional] +export const createGovernanceInstruction = ( + governanceAccount: PublicKey, + governedProgramAccount: PublicKey, + governedProgramDataAccount: PublicKey, + governedProgramUpgradeAuthority: PublicKey, + governanceMint: PublicKey, + voteThreshold: number, + minimumSlotWaitingPeriod: BN, + timeLimit: BN, + name: string, + payer: PublicKey, + councilMint?: PublicKey, +): TransactionInstruction => { + const PROGRAM_IDS = utils.programIds(); + + if (name.length > GOVERNANCE_NAME_LENGTH) { + throw new Error('Name is more than ' + GOVERNANCE_NAME_LENGTH); + } + + const dataLayout = BufferLayout.struct([ + BufferLayout.u8('instruction'), + BufferLayout.u8('voteThreshold'), + Layout.uint64('minimumSlotWaitingPeriod'), + Layout.uint64('timeLimit'), + BufferLayout.seq(BufferLayout.u8(), GOVERNANCE_NAME_LENGTH, 'name'), + ]); + + const nameAsBytes = utils.toUTF8Array(name); + for (let i = nameAsBytes.length; i <= GOVERNANCE_NAME_LENGTH - 1; i++) { + nameAsBytes.push(0); + } + + const data = Buffer.alloc(dataLayout.span); + + dataLayout.encode( + { + instruction: GovernanceInstruction.CreateGovernance, + voteThreshold, + minimumSlotWaitingPeriod, + timeLimit, + name: nameAsBytes, + }, + data, + ); + + const keys = [ + { pubkey: governanceAccount, isSigner: false, isWritable: true }, + { pubkey: governedProgramAccount, isSigner: false, isWritable: false }, + { pubkey: governedProgramDataAccount, isSigner: false, isWritable: true }, + { + pubkey: governedProgramUpgradeAuthority, + isSigner: true, + isWritable: false, + }, + { pubkey: governanceMint, isSigner: false, isWritable: false }, + { pubkey: payer, isSigner: true, isWritable: false }, + { pubkey: PROGRAM_IDS.system, isSigner: false, isWritable: false }, + { + pubkey: PROGRAM_IDS.bpf_upgrade_loader, + isSigner: false, + isWritable: false, + }, + ]; + + if (councilMint) { + keys.push({ pubkey: councilMint, isSigner: false, isWritable: false }); + } + + return new TransactionInstruction({ + keys, + programId: PROGRAM_IDS.governance.programId, + data, + }); +}; diff --git a/packages/proposals/src/models/depositSourceTokens.ts b/packages/governance/src/models/depositSourceTokens.ts similarity index 76% rename from packages/proposals/src/models/depositSourceTokens.ts rename to packages/governance/src/models/depositSourceTokens.ts index 755635b..4ccef75 100644 --- a/packages/proposals/src/models/depositSourceTokens.ts +++ b/packages/governance/src/models/depositSourceTokens.ts @@ -3,22 +3,22 @@ import { utils } from '@oyster/common'; import * as Layout from '../utils/layout'; import * as BufferLayout from 'buffer-layout'; -import { TimelockInstruction } from './timelock'; +import { GovernanceInstruction } from './governance'; import BN from 'bn.js'; -/// [Requires tokens of the Governance mint or Council mint depending on type of TimelockSet] -/// Deposits voting tokens to be used during the voting process in a timelock. +/// [Requires tokens of the Governance mint or Council mint depending on type of Proposal] +/// Deposits voting tokens to be used during the voting process in a Proposal. /// These tokens are removed from your account and can be returned by withdrawing -/// them from the timelock (but then you will miss the vote.) +/// them from the Proposal (but then you will miss the vote.) /// /// 0. `[writable]` Governance voting record account. See Vote docs for more detail. /// 1. `[writable]` Initialized Voting account to hold your received voting tokens. /// 2. `[writable]` User token account to deposit tokens from. -/// 3. `[writable]` Source holding account for timelock that will accept the tokens in escrow. +/// 3. `[writable]` Source holding account for Proposal that will accept the tokens in escrow. /// 4. `[writable]` Voting mint account. -/// 5. `[]` Timelock set account. +/// 5. `[]` Proposal account. /// 6. `[]` Transfer authority -/// 7. `[]` Timelock program mint authority +/// 7. `[]` Governance program mint authority (pda with seed of Proposal key) /// 8. `[]` Token program account. export const depositSourceTokensInstruction = ( governanceVotingRecord: PublicKey, @@ -26,7 +26,7 @@ export const depositSourceTokensInstruction = ( sourceAccount: PublicKey, sourceHoldingAccount: PublicKey, votingMint: PublicKey, - timelockSetAccount: PublicKey, + proposalAccount: PublicKey, transferAuthority: PublicKey, mintAuthority: PublicKey, votingTokenAmount: number, @@ -42,7 +42,7 @@ export const depositSourceTokensInstruction = ( dataLayout.encode( { - instruction: TimelockInstruction.DepositGovernanceTokens, + instruction: GovernanceInstruction.DepositGovernanceTokens, votingTokenAmount: new BN(votingTokenAmount), }, data, @@ -54,15 +54,15 @@ export const depositSourceTokensInstruction = ( { pubkey: sourceAccount, isSigner: false, isWritable: true }, { pubkey: sourceHoldingAccount, isSigner: false, isWritable: true }, { pubkey: votingMint, isSigner: false, isWritable: true }, - { pubkey: timelockSetAccount, isSigner: false, isWritable: false }, - { pubkey: transferAuthority, isSigner: false, isWritable: false }, + { pubkey: proposalAccount, isSigner: false, isWritable: false }, + { pubkey: transferAuthority, isSigner: true, isWritable: false }, { pubkey: mintAuthority, isSigner: false, isWritable: false }, { pubkey: PROGRAM_IDS.token, isSigner: false, isWritable: false }, ]; return new TransactionInstruction({ keys, - programId: PROGRAM_IDS.timelock.programId, + programId: PROGRAM_IDS.governance.programId, data, }); }; diff --git a/packages/proposals/src/models/execute.ts b/packages/governance/src/models/execute.ts similarity index 58% rename from packages/proposals/src/models/execute.ts rename to packages/governance/src/models/execute.ts index 5a56361..e6fe03b 100644 --- a/packages/proposals/src/models/execute.ts +++ b/packages/governance/src/models/execute.ts @@ -5,38 +5,37 @@ import { } from '@solana/web3.js'; import { utils } from '@oyster/common'; import * as BufferLayout from 'buffer-layout'; -import { TimelockInstruction } from './timelock'; +import { GovernanceInstruction } from './governance'; -/// Executes a command in the timelock set. +/// Executes a command in the Proposal /// /// 0. `[writable]` Transaction account you wish to execute. -/// 1. `[writable]` Timelock state account. +/// 1. `[writable]` Proposal state account. /// 2. `[]` Program being invoked account -/// 3. `[]` Timelock set account. -/// 4. `[]` Timelock config -/// 5. `[]` Clock sysvar. +/// 3. `[]` Proposal account. +/// 4. `[]` Governance account +/// 5. `[]` Governance program account pub key. +/// 6. `[]` Clock sysvar. /// 7+ Any extra accounts that are part of the instruction, in order export const executeInstruction = ( transactionAccount: PublicKey, - timelockStateAccount: PublicKey, - timelockSetAccount: PublicKey, + proposalStateAccount: PublicKey, + proposalAccount: PublicKey, programBeingInvokedAccount: PublicKey, - timelockConfig: PublicKey, + governance: PublicKey, accountInfos: { pubkey: PublicKey; isWritable: boolean; isSigner: boolean }[], ): TransactionInstruction => { const PROGRAM_IDS = utils.programIds(); - const dataLayout = BufferLayout.struct([ - BufferLayout.u8('instruction'), - BufferLayout.u8('numberOfExtraAccounts'), - ]); + const dataLayout = BufferLayout.struct([BufferLayout.u8('instruction')]); const data = Buffer.alloc(dataLayout.span); + console.log('ACCTS', accountInfos); + dataLayout.encode( { - instruction: TimelockInstruction.Execute, - numberOfExtraAccounts: accountInfos.length, + instruction: GovernanceInstruction.Execute, }, data, ); @@ -44,16 +43,16 @@ export const executeInstruction = ( const keys = [ // just a note this were all set to writable true...come back and check on this { pubkey: transactionAccount, isSigner: false, isWritable: true }, - { pubkey: timelockStateAccount, isSigner: false, isWritable: true }, + { pubkey: proposalStateAccount, isSigner: false, isWritable: true }, { pubkey: programBeingInvokedAccount, isSigner: false, isWritable: false }, - { pubkey: timelockSetAccount, isSigner: false, isWritable: false }, - { pubkey: timelockConfig, isSigner: false, isWritable: false }, + { pubkey: proposalAccount, isSigner: false, isWritable: false }, + { pubkey: governance, isSigner: false, isWritable: false }, { pubkey: SYSVAR_CLOCK_PUBKEY, isSigner: false, isWritable: false }, ...accountInfos, ]; return new TransactionInstruction({ keys, - programId: PROGRAM_IDS.timelock.programId, + programId: PROGRAM_IDS.governance.programId, data, }); }; diff --git a/packages/proposals/src/models/timelock.ts b/packages/governance/src/models/governance.ts similarity index 64% rename from packages/proposals/src/models/timelock.ts rename to packages/governance/src/models/governance.ts index 1904616..91fe6bf 100644 --- a/packages/proposals/src/models/timelock.ts +++ b/packages/governance/src/models/governance.ts @@ -6,36 +6,37 @@ import { utils } from '@oyster/common'; export const DESC_SIZE = 200; export const NAME_SIZE = 32; -export const CONFIG_NAME_LENGTH = 32; +export const GOVERNANCE_NAME_LENGTH = 32; export const INSTRUCTION_LIMIT = 450; -export const TRANSACTION_SLOTS = 5; +export const MAX_TRANSACTIONS = 5; export const TEMP_FILE_TXN_SIZE = 1000; -// Key chosen to represent an unused key, a dummy empty. Points to system program. -export const ZERO_KEY = '11111111111111111111111111111111'; -export enum TimelockInstruction { - InitTimelockSet = 1, +/// Seed for proposal authority +export const GOVERNANCE_AUTHORITY_SEED = 'governance'; + +export enum GovernanceInstruction { + InitProposal = 1, AddSigner = 2, RemoveSigner = 3, AddCustomSingleSignerTransaction = 4, Sign = 8, Vote = 9, - InitTimelockConfig = 10, - Ping = 11, - Execute = 12, - DepositGovernanceTokens = 13, - WithdrawVotingTokens = 14, - CreateEmptyTimelockConfig = 15, - CreateGovernanceVotingRecord = 16, + CreateGovernance = 10, + + Execute = 11, + DepositGovernanceTokens = 12, + WithdrawVotingTokens = 13, + CreateGovernanceVotingRecord = 14, } export interface GovernanceVotingRecord { + /// Account type + accountType: GovernanceAccountType; /// proposal proposal: PublicKey; /// owner owner: PublicKey; - ///version - version: number; + /// How many votes were unspent undecidedCount: BN; /// How many votes were spent yes @@ -46,32 +47,28 @@ export interface GovernanceVotingRecord { export const GovernanceVotingRecordLayout: typeof BufferLayout.Structure = BufferLayout.struct( [ + BufferLayout.u8('accountType'), Layout.publicKey('proposal'), Layout.publicKey('owner'), - BufferLayout.u8('version'), Layout.uint64('undecidedCount'), Layout.uint64('yesCount'), Layout.uint64('noCount'), BufferLayout.seq(BufferLayout.u8(), 100, 'padding'), ], ); -export interface TimelockConfig { - ///version - version: number; - /// Consensus Algorithm - consensusAlgorithm: ConsensusAlgorithm; - /// Execution type - executionType: ExecutionType; - /// Timelock Type - timelockType: TimelockType; - /// Voting entry rule - votingEntryRule: VotingEntryRule; + +export interface Governance { + /// Account type + accountType: GovernanceAccountType; + /// Vote threshold + voteThreshold: number; + /// Minimum slot time-distance from creation of proposal for an instruction to be placed minimumSlotWaitingPeriod: BN; /// Governance mint governanceMint: PublicKey; /// Council mint (Optional) - councilMint: PublicKey; + councilMint?: PublicKey; /// Program ID that is tied to this config (optional) program: PublicKey; /// Time limit in slots for proposal to be open to voting @@ -82,43 +79,32 @@ export interface TimelockConfig { count: number; } -export const TimelockConfigLayout: typeof BufferLayout.Structure = BufferLayout.struct( +export enum GovernanceAccountType { + Uninitialized = 0, + Governance = 1, + Proposal = 2, + ProposalState = 3, + VoteRecord = 4, + CustomSingleSignerTransaction = 5, +} + +export const GovernanceLayout: typeof BufferLayout.Structure = BufferLayout.struct( [ - BufferLayout.u8('version'), - BufferLayout.u8('consensusAlgorithm'), - BufferLayout.u8('executionType'), - BufferLayout.u8('timelockType'), - BufferLayout.u8('votingEntryRule'), + BufferLayout.u8('accountType'), + BufferLayout.u8('voteThreshold'), Layout.uint64('minimumSlotWaitingPeriod'), Layout.publicKey('governanceMint'), + BufferLayout.u8('councilMintOption'), Layout.publicKey('councilMint'), Layout.publicKey('program'), Layout.uint64('timeLimit'), - BufferLayout.seq(BufferLayout.u8(), CONFIG_NAME_LENGTH, 'name'), + BufferLayout.seq(BufferLayout.u8(), GOVERNANCE_NAME_LENGTH, 'name'), BufferLayout.u32('count'), - BufferLayout.seq(BufferLayout.u8(), 296, 'padding'), + BufferLayout.seq(BufferLayout.u8(), 295, 'padding'), ], ); -export enum VotingEntryRule { - Anytime = 0, -} - -export enum ConsensusAlgorithm { - Majority = 0, - SuperMajority = 1, - FullConsensus = 2, -} - -export enum ExecutionType { - Independent = 0, -} - -export enum TimelockType { - CustomSingleSignerV1 = 0, -} - -export enum TimelockStateStatus { +export enum ProposalStateStatus { /// Draft Draft = 0, /// Taking votes @@ -138,20 +124,21 @@ export enum TimelockStateStatus { } export const STATE_COLOR: Record = { - [TimelockStateStatus.Draft]: 'orange', - [TimelockStateStatus.Voting]: 'blue', - [TimelockStateStatus.Executing]: 'green', - [TimelockStateStatus.Completed]: 'purple', - [TimelockStateStatus.Deleted]: 'gray', - [TimelockStateStatus.Defeated]: 'red', + [ProposalStateStatus.Draft]: 'orange', + [ProposalStateStatus.Voting]: 'blue', + [ProposalStateStatus.Executing]: 'green', + [ProposalStateStatus.Completed]: 'purple', + [ProposalStateStatus.Deleted]: 'gray', + [ProposalStateStatus.Defeated]: 'red', }; -export interface TimelockState { - timelockSet: PublicKey; - version: number; - status: TimelockStateStatus; +export interface ProposalState { + /// Account type + accountType: GovernanceAccountType; + proposal: PublicKey; + status: ProposalStateStatus; totalSigningTokensMinted: BN; - timelockTransactions: PublicKey[]; + proposalTransactions: PublicKey[]; name: string; descLink: string; votingEndedAt: BN; @@ -163,17 +150,16 @@ export interface TimelockState { usedTxnSlots: number; } -const timelockTxns = []; -for (let i = 0; i < TRANSACTION_SLOTS; i++) { - timelockTxns.push(Layout.publicKey('timelockTxn' + i.toString())); +const proposalTxns = []; +for (let i = 0; i < MAX_TRANSACTIONS; i++) { + proposalTxns.push(Layout.publicKey('proposalTxn' + i.toString())); } -export const TimelockSetLayout: typeof BufferLayout.Structure = BufferLayout.struct( +export const ProposalLayout: typeof BufferLayout.Structure = BufferLayout.struct( [ + BufferLayout.u8('accountType'), Layout.publicKey('config'), - Layout.publicKey('tokenProgramId'), Layout.publicKey('state'), - BufferLayout.u8('version'), Layout.publicKey('signatoryMint'), Layout.publicKey('adminMint'), Layout.publicKey('votingMint'), @@ -184,17 +170,16 @@ export const TimelockSetLayout: typeof BufferLayout.Structure = BufferLayout.str Layout.publicKey('adminValidation'), Layout.publicKey('votingValidation'), Layout.publicKey('sourceHolding'), - Layout.publicKey('yesVotingDump'), - Layout.publicKey('noVotingDump'), + BufferLayout.seq(BufferLayout.u8(), 300, 'padding'), ], ); -export const TimelockStateLayout: typeof BufferLayout.Structure = BufferLayout.struct( +export const ProposalStateLayout: typeof BufferLayout.Structure = BufferLayout.struct( [ - Layout.publicKey('timelockSet'), - BufferLayout.u8('version'), - BufferLayout.u8('timelockStateStatus'), + BufferLayout.u8('accountType'), + Layout.publicKey('proposal'), + BufferLayout.u8('proposalStateStatus'), Layout.uint64('totalSigningTokensMinted'), BufferLayout.seq(BufferLayout.u8(), DESC_SIZE, 'descLink'), BufferLayout.seq(BufferLayout.u8(), NAME_SIZE, 'name'), @@ -205,24 +190,21 @@ export const TimelockStateLayout: typeof BufferLayout.Structure = BufferLayout.s Layout.uint64('deletedAt'), BufferLayout.u8('executions'), BufferLayout.u8('usedTxnSlots'), - ...timelockTxns, + ...proposalTxns, BufferLayout.seq(BufferLayout.u8(), 300, 'padding'), ], ); -export interface TimelockSet { +export interface Proposal { + /// Account type + accountType: GovernanceAccountType; + /// configuration values config: PublicKey; - /// Token Program ID - tokenProgramId: PublicKey; - /// state values state: PublicKey; - /// Version of the struct - version: number; - /// Mint that creates signatory tokens of this instruction /// If there are outstanding signatory tokens, then cannot leave draft state. Signatories must burn tokens (ie agree /// to move instruction to voting state) and bring mint to net 0 tokens outstanding. Each signatory gets 1 (serves as flag) @@ -254,17 +236,11 @@ export interface TimelockSet { /// Governance holding account sourceHolding: PublicKey; - - /// Yes Voting dump account for exchanged vote tokens - yesVotingDump: PublicKey; - - /// No Voting dump account for exchanged vote tokens - noVotingDump: PublicKey; } -export const CustomSingleSignerTimelockTransactionLayout: typeof BufferLayout.Structure = BufferLayout.struct( +export const CustomSingleSignerTransactionLayout: typeof BufferLayout.Structure = BufferLayout.struct( [ - BufferLayout.u8('version'), + BufferLayout.u8('accountType'), Layout.uint64('slot'), BufferLayout.seq(BufferLayout.u8(), INSTRUCTION_LIMIT, 'instruction'), BufferLayout.u8('executed'), @@ -273,8 +249,9 @@ export const CustomSingleSignerTimelockTransactionLayout: typeof BufferLayout.St ], ); -export interface TimelockTransaction { - version: number; +export interface GovernanceTransaction { + /// Account type + accountType: GovernanceAccountType; slot: BN; @@ -284,25 +261,23 @@ export interface TimelockTransaction { instructionEndIndex: number; } -export interface CustomSingleSignerTimelockTransaction - extends TimelockTransaction {} +export interface CustomSingleSignerTransaction extends GovernanceTransaction {} -export const TimelockSetParser = ( +export const ProposalParser = ( pubKey: PublicKey, info: AccountInfo, ) => { const buffer = Buffer.from(info.data); - const data = TimelockSetLayout.decode(buffer); + const data = ProposalLayout.decode(buffer); const details = { pubkey: pubKey, account: { ...info, }, info: { + accountType: data.accountType, config: data.config, - tokenProgramId: data.tokenProgramId, state: data.state, - version: data.version, signatoryMint: data.signatoryMint, adminMint: data.adminMint, votingMint: data.votingMint, @@ -313,8 +288,6 @@ export const TimelockSetParser = ( adminValidation: data.adminValidation, votingValidation: data.votingValidation, sourceHolding: data.sourceHolding, - yesVotingDump: data.yesVotingDump, - noVotingDump: data.noVotingDump, }, }; @@ -333,9 +306,9 @@ export const GovernanceVotingRecordParser = ( ...info, }, info: { + accountType: data.accountType, proposal: data.proposal, owner: data.owner, - version: data.version, undecidedCount: data.undecidedCount, yesCount: data.yesCount, noCount: data.noCount, @@ -345,16 +318,16 @@ export const GovernanceVotingRecordParser = ( return details; }; -export const TimelockStateParser = ( +export const ProposalStateParser = ( pubKey: PublicKey, info: AccountInfo, ) => { const buffer = Buffer.from(info.data); - const data = TimelockStateLayout.decode(buffer); + const data = ProposalStateLayout.decode(buffer); - const timelockTxns = []; - for (let i = 0; i < TRANSACTION_SLOTS; i++) { - timelockTxns.push(data['timelockTxn' + i.toString()]); + const proposalTxns = []; + for (let i = 0; i < MAX_TRANSACTIONS; i++) { + proposalTxns.push(data['proposalTxn' + i.toString()]); } const details = { @@ -363,13 +336,13 @@ export const TimelockStateParser = ( ...info, }, info: { - version: data.version, - timelockSet: data.timelockSet, - status: data.timelockStateStatus, + accountType: data.accountType, + proposal: data.proposal, + status: data.proposalStateStatus, totalSigningTokensMinted: data.totalSigningTokensMinted, descLink: utils.fromUTF8Array(data.descLink).replaceAll('\u0000', ''), name: utils.fromUTF8Array(data.name).replaceAll('\u0000', ''), - timelockTransactions: timelockTxns, + proposalTransactions: proposalTxns, votingEndedAt: data.votingEndedAt, votingBeganAt: data.votingBeganAt, createdAt: data.createdAt, @@ -383,12 +356,12 @@ export const TimelockStateParser = ( return details; }; -export const CustomSingleSignerTimelockTransactionParser = ( +export const CustomSingleSignerTransactionParser = ( pubKey: PublicKey, info: AccountInfo, ) => { const buffer = Buffer.from(info.data); - const data = CustomSingleSignerTimelockTransactionLayout.decode(buffer); + const data = CustomSingleSignerTransactionLayout.decode(buffer); const details = { pubkey: pubKey, @@ -396,7 +369,7 @@ export const CustomSingleSignerTimelockTransactionParser = ( ...info, }, info: { - version: data.version, + accountType: data.accountType, slot: data.slot, instruction: data.instruction.slice(0, data.instructionEndIndex + 1), @@ -408,12 +381,12 @@ export const CustomSingleSignerTimelockTransactionParser = ( return details; }; -export const TimelockConfigParser = ( +export const GovernanceParser = ( pubKey: PublicKey, info: AccountInfo, ) => { const buffer = Buffer.from(info.data); - const data = TimelockConfigLayout.decode(buffer); + const data = GovernanceLayout.decode(buffer); const details = { pubkey: pubKey, @@ -421,14 +394,12 @@ export const TimelockConfigParser = ( ...info, }, info: { - version: data.version, - consensusAlgorithm: data.consensusAlgorithm, - executionType: data.executionType, - timelockType: data.timelockType, - votingEntryRule: data.votingEntryRule, + accountType: data.accountType, + voteThreshold: data.voteThreshold, + minimumSlotWaitingPeriod: data.minimumSlotWaitingPeriod, governanceMint: data.governanceMint, - councilMint: data.councilMint, + councilMint: data.councilMintOption === 1 ? data.councilMint : null, program: data.program, timeLimit: data.timeLimit, name: utils.fromUTF8Array(data.name).replaceAll('\u0000', ''), diff --git a/packages/proposals/src/models/initTimelockSet.ts b/packages/governance/src/models/initProposal.ts similarity index 74% rename from packages/proposals/src/models/initTimelockSet.ts rename to packages/governance/src/models/initProposal.ts index 8feda01..0f3be15 100644 --- a/packages/proposals/src/models/initTimelockSet.ts +++ b/packages/governance/src/models/initProposal.ts @@ -5,14 +5,14 @@ import { } from '@solana/web3.js'; import { utils } from '@oyster/common'; import * as BufferLayout from 'buffer-layout'; -import { DESC_SIZE, NAME_SIZE, TimelockInstruction } from './timelock'; +import { DESC_SIZE, NAME_SIZE, GovernanceInstruction } from './governance'; -/// Initializes a new empty Timelocked set of Instructions that will be executed at various slots in the future in draft mode. +/// Initializes a new empty Proposal for Instructions that will be executed at various slots in the future in draft mode. /// Grants Admin token to caller. /// -/// 0. `[writable]` Uninitialized Timelock state account . -/// 1. `[writable]` Uninitialized Timelock set account . -/// 2. `[writable]` Initialized Timelock config account. +/// 0. `[writable]` Uninitialized Proposal state account . +/// 1. `[writable]` Uninitialized Proposal account . +/// 2. `[writable]` Initialized Governance account. /// 3. `[writable]` Initialized Signatory Mint account /// 4. `[writable]` Initialized Admin Mint account /// 5. `[writable]` Initialized Voting Mint account @@ -23,17 +23,15 @@ import { DESC_SIZE, NAME_SIZE, TimelockInstruction } from './timelock'; /// 10. `[writable]` Initialized Voting Validation account /// 11. `[writable]` Initialized Destination account for first admin token /// 12. `[writable]` Initialized Destination account for first signatory token -/// 13. `[writable]` Initialized Yes voting dump account -/// 14. `[writable]` Initialized No voting dump account /// 15. `[writable]` Initialized source holding account /// 16. `[]` Source mint -/// 17. `[]` Timelock minting authority +/// 17. `[]` Governance minting authority (pda with seed of Proposal key) /// 18. '[]` Token program id /// 19. `[]` Rent sysvar -export const initTimelockSetInstruction = ( - timelockStateAccount: PublicKey, - timelockSetAccount: PublicKey, - timelockConfigAccount: PublicKey, +export const initProposalInstruction = ( + proposalStateAccount: PublicKey, + proposalAccount: PublicKey, + governanceAccount: PublicKey, signatoryMintAccount: PublicKey, adminMintAccount: PublicKey, votingMintAccount: PublicKey, @@ -44,8 +42,6 @@ export const initTimelockSetInstruction = ( votingValidationAccount: PublicKey, destinationAdminAccount: PublicKey, destinationSignatoryAccount: PublicKey, - yesVotingDumpAccount: PublicKey, - noVotingDumpAccount: PublicKey, sourceHoldingAccount: PublicKey, sourceMintAccount: PublicKey, authority: PublicKey, @@ -80,7 +76,7 @@ export const initTimelockSetInstruction = ( dataLayout.encode( { - instruction: TimelockInstruction.InitTimelockSet, + instruction: GovernanceInstruction.InitProposal, descLink: descAsBytes, name: nameAsBytes, }, @@ -88,9 +84,9 @@ export const initTimelockSetInstruction = ( ); const keys = [ - { pubkey: timelockStateAccount, isSigner: true, isWritable: true }, - { pubkey: timelockSetAccount, isSigner: true, isWritable: true }, - { pubkey: timelockConfigAccount, isSigner: false, isWritable: true }, + { pubkey: proposalStateAccount, isSigner: true, isWritable: true }, + { pubkey: proposalAccount, isSigner: true, isWritable: true }, + { pubkey: governanceAccount, isSigner: false, isWritable: true }, { pubkey: signatoryMintAccount, isSigner: false, isWritable: true }, { pubkey: adminMintAccount, isSigner: false, isWritable: true }, { pubkey: votingMintAccount, isSigner: false, isWritable: true }, @@ -101,8 +97,6 @@ export const initTimelockSetInstruction = ( { pubkey: votingValidationAccount, isSigner: false, isWritable: true }, { pubkey: destinationAdminAccount, isSigner: false, isWritable: true }, { pubkey: destinationSignatoryAccount, isSigner: false, isWritable: true }, - { pubkey: yesVotingDumpAccount, isSigner: false, isWritable: true }, - { pubkey: noVotingDumpAccount, isSigner: false, isWritable: true }, { pubkey: sourceHoldingAccount, isSigner: false, isWritable: true }, { pubkey: sourceMintAccount, @@ -115,7 +109,7 @@ export const initTimelockSetInstruction = ( ]; return new TransactionInstruction({ keys, - programId: PROGRAM_IDS.timelock.programId, + programId: PROGRAM_IDS.governance.programId, data, }); }; diff --git a/packages/proposals/src/models/removeSigner.ts b/packages/governance/src/models/removeSigner.ts similarity index 75% rename from packages/proposals/src/models/removeSigner.ts rename to packages/governance/src/models/removeSigner.ts index 6dec5a7..72afff6 100644 --- a/packages/proposals/src/models/removeSigner.ts +++ b/packages/governance/src/models/removeSigner.ts @@ -1,7 +1,7 @@ import { PublicKey, TransactionInstruction } from '@solana/web3.js'; import { utils } from '@oyster/common'; import * as BufferLayout from 'buffer-layout'; -import { TimelockInstruction } from './timelock'; +import { GovernanceInstruction } from './governance'; /// [Requires Admin token] /// Removes a signer from the set. @@ -10,16 +10,17 @@ import { TimelockInstruction } from './timelock'; /// 1. `[writable]` Signatory mint account. /// 2. `[writable]` Admin account. /// 3. `[writable]` Admin validation account. -/// 4. `[]` Timelock set account. -/// 5. `[]` Transfer authority -/// 6. `[]` Timelock program mint authority -/// 7. '[]` Token program id. +/// 4. `[writable]` Proposal state account. +/// 5. `[]` Proposal account. +/// 6. `[]` Transfer authority +/// 7. `[]` Governance program mint authority (pda of seed with Proposal key) +/// 8. '[]` Token program id. export const removeSignerInstruction = ( signatoryAccount: PublicKey, signatoryMintAccount: PublicKey, adminAccount: PublicKey, adminValidationAccount: PublicKey, - timelockSetAccount: PublicKey, + proposalAccount: PublicKey, transferAuthority: PublicKey, mintAuthority: PublicKey, ): TransactionInstruction => { @@ -31,7 +32,7 @@ export const removeSignerInstruction = ( dataLayout.encode( { - instruction: TimelockInstruction.RemoveSigner, + instruction: GovernanceInstruction.RemoveSigner, }, data, ); @@ -41,14 +42,14 @@ export const removeSignerInstruction = ( { pubkey: signatoryMintAccount, isSigner: false, isWritable: true }, { pubkey: adminAccount, isSigner: false, isWritable: true }, { pubkey: adminValidationAccount, isSigner: false, isWritable: true }, - { pubkey: timelockSetAccount, isSigner: false, isWritable: true }, + { pubkey: proposalAccount, isSigner: false, isWritable: true }, { pubkey: transferAuthority, isSigner: true, isWritable: false }, { pubkey: mintAuthority, isSigner: false, isWritable: false }, { pubkey: PROGRAM_IDS.token, isSigner: false, isWritable: false }, ]; return new TransactionInstruction({ keys, - programId: PROGRAM_IDS.timelock.programId, + programId: PROGRAM_IDS.governance.programId, data, }); }; diff --git a/packages/proposals/src/models/sign.ts b/packages/governance/src/models/sign.ts similarity index 69% rename from packages/proposals/src/models/sign.ts rename to packages/governance/src/models/sign.ts index 54048e9..be28b58 100644 --- a/packages/proposals/src/models/sign.ts +++ b/packages/governance/src/models/sign.ts @@ -5,25 +5,25 @@ import { } from '@solana/web3.js'; import { utils } from '@oyster/common'; import * as BufferLayout from 'buffer-layout'; -import { TimelockInstruction } from './timelock'; +import { GovernanceInstruction } from './governance'; /// [Requires Signatory token] -/// Burns signatory token, indicating you approve of moving this Timelock set from Draft state to Voting state. +/// Burns signatory token, indicating you approve of moving this Proposal from Draft state to Voting state. /// The last Signatory token to be burned moves the state to Voting. /// -/// 0. `[writable]` Timelock state account pub key. +/// 0. `[writable]` Proposal state account pub key. /// 1. `[writable]` Signatory account /// 2. `[writable]` Signatory mint account. -/// 3. `[]` Timelock set account pub key. +/// 3. `[]` Proposal account pub key. /// 4. `[]` Transfer authority -/// 5. `[]` Timelock mint authority -/// 6. `[]` Token program account. -/// 7. `[]` Clock sysvar. +/// 5. `[]` Governance mint authority (pda of seed Proposal key) +/// 7. `[]` Token program account. +/// 8. `[]` Clock sysvar. export const signInstruction = ( - timelockStateAccount: PublicKey, + proposalStateAccount: PublicKey, signatoryAccount: PublicKey, signatoryMintAccount: PublicKey, - timelockSetAccount: PublicKey, + proposalAccount: PublicKey, transferAuthority: PublicKey, mintAuthority: PublicKey, ): TransactionInstruction => { @@ -35,16 +35,16 @@ export const signInstruction = ( dataLayout.encode( { - instruction: TimelockInstruction.Sign, + instruction: GovernanceInstruction.Sign, }, data, ); const keys = [ - { pubkey: timelockStateAccount, isSigner: false, isWritable: true }, + { pubkey: proposalStateAccount, isSigner: false, isWritable: true }, { pubkey: signatoryAccount, isSigner: false, isWritable: true }, { pubkey: signatoryMintAccount, isSigner: false, isWritable: true }, - { pubkey: timelockSetAccount, isSigner: false, isWritable: false }, + { pubkey: proposalAccount, isSigner: false, isWritable: false }, { pubkey: transferAuthority, isSigner: true, isWritable: false }, { pubkey: mintAuthority, isSigner: false, isWritable: false }, { pubkey: PROGRAM_IDS.token, isSigner: false, isWritable: false }, @@ -52,7 +52,7 @@ export const signInstruction = ( ]; return new TransactionInstruction({ keys, - programId: PROGRAM_IDS.timelock.programId, + programId: PROGRAM_IDS.governance.programId, data, }); }; diff --git a/packages/proposals/src/models/vote.ts b/packages/governance/src/models/vote.ts similarity index 79% rename from packages/proposals/src/models/vote.ts rename to packages/governance/src/models/vote.ts index bf8841d..beed2d9 100644 --- a/packages/proposals/src/models/vote.ts +++ b/packages/governance/src/models/vote.ts @@ -7,17 +7,17 @@ import { utils } from '@oyster/common'; import * as Layout from '../utils/layout'; import * as BufferLayout from 'buffer-layout'; -import { TimelockInstruction } from './timelock'; +import { GovernanceInstruction } from './governance'; import BN from 'bn.js'; /// [Requires Voting tokens] /// Burns voting tokens, indicating you approve and/or disapprove of running this set of transactions. If you tip the consensus, -/// then the transactions can begin to be run at their time slots when people click execute. +/// then the transactions can begin to be run at their time slots when people click execute. You are then given yes and/or no tokens. /// /// 0. `[writable]` Governance voting record account. /// Can be uninitialized or initialized(if already used once in this proposal) -/// Must have address with PDA having seed tuple [timelock acct key, proposal key, your voting account key] -/// 1. `[writable]` Timelock state account. +/// Must have address with PDA having seed tuple [Governance acct key, proposal key, your voting account key] +/// 1. `[writable]` Proposal state account. /// 2. `[writable]` Your Voting account. /// 3. `[writable]` Your Yes-Voting account. /// 4. `[writable]` Your No-Voting account. @@ -25,15 +25,15 @@ import BN from 'bn.js'; /// 6. `[writable]` Yes Voting mint account. /// 7. `[writable]` No Voting mint account. /// 8. `[]` Source mint account -/// 9. `[]` Timelock set account. -/// 10. `[]` Timelock config account. +/// 9. `[]` Proposal account. +/// 10. `[]` Governance account. /// 12. `[]` Transfer authority -/// 13. `[]` Timelock program mint authority +/// 13. `[]` Governance program mint authority (pda of seed Proposal key) /// 14. `[]` Token program account. /// 15. `[]` Clock sysvar. export const voteInstruction = ( governanceVotingRecord: PublicKey, - timelockStateAccount: PublicKey, + proposalStateAccount: PublicKey, votingAccount: PublicKey, yesVotingAccount: PublicKey, noVotingAccount: PublicKey, @@ -41,8 +41,8 @@ export const voteInstruction = ( yesVotingMint: PublicKey, noVotingMint: PublicKey, sourceMint: PublicKey, - timelockSetAccount: PublicKey, - timelockConfig: PublicKey, + proposalAccount: PublicKey, + governance: PublicKey, transferAuthority: PublicKey, mintAuthority: PublicKey, yesVotingTokenAmount: number, @@ -60,7 +60,7 @@ export const voteInstruction = ( dataLayout.encode( { - instruction: TimelockInstruction.Vote, + instruction: GovernanceInstruction.Vote, yesVotingTokenAmount: new BN(yesVotingTokenAmount), noVotingTokenAmount: new BN(noVotingTokenAmount), }, @@ -69,7 +69,7 @@ export const voteInstruction = ( const keys = [ { pubkey: governanceVotingRecord, isSigner: false, isWritable: true }, - { pubkey: timelockStateAccount, isSigner: false, isWritable: true }, + { pubkey: proposalStateAccount, isSigner: false, isWritable: true }, { pubkey: votingAccount, isSigner: false, isWritable: true }, { pubkey: yesVotingAccount, isSigner: false, isWritable: true }, { pubkey: noVotingAccount, isSigner: false, isWritable: true }, @@ -77,8 +77,8 @@ export const voteInstruction = ( { pubkey: yesVotingMint, isSigner: false, isWritable: true }, { pubkey: noVotingMint, isSigner: false, isWritable: true }, { pubkey: sourceMint, isSigner: false, isWritable: false }, - { pubkey: timelockSetAccount, isSigner: false, isWritable: false }, - { pubkey: timelockConfig, isSigner: false, isWritable: false }, + { pubkey: proposalAccount, isSigner: false, isWritable: false }, + { pubkey: governance, isSigner: false, isWritable: false }, { pubkey: transferAuthority, isSigner: true, isWritable: false }, { pubkey: mintAuthority, isSigner: false, isWritable: false }, { pubkey: PROGRAM_IDS.token, isSigner: false, isWritable: false }, @@ -87,7 +87,7 @@ export const voteInstruction = ( return new TransactionInstruction({ keys, - programId: PROGRAM_IDS.timelock.programId, + programId: PROGRAM_IDS.governance.programId, data, }); }; diff --git a/packages/proposals/src/models/withdrawVotingTokens.ts b/packages/governance/src/models/withdrawVotingTokens.ts similarity index 71% rename from packages/proposals/src/models/withdrawVotingTokens.ts rename to packages/governance/src/models/withdrawVotingTokens.ts index f488e5d..bb858b0 100644 --- a/packages/proposals/src/models/withdrawVotingTokens.ts +++ b/packages/governance/src/models/withdrawVotingTokens.ts @@ -3,24 +3,25 @@ import { utils } from '@oyster/common'; import * as Layout from '../utils/layout'; import * as BufferLayout from 'buffer-layout'; -import { TimelockInstruction } from './timelock'; +import { GovernanceInstruction } from './governance'; import BN from 'bn.js'; +/// [Requires voting tokens] +/// Withdraws voting tokens. +/// /// 0. `[writable]` Governance voting record account. See Vote docs for more detail. /// 1. `[writable]` Initialized Voting account from which to remove your voting tokens. /// 2. `[writable]` Initialized Yes Voting account from which to remove your voting tokens. /// 3. `[writable]` Initialized No Voting account from which to remove your voting tokens. /// 4. `[writable]` User token account that you wish your actual tokens to be returned to. -/// 5. `[writable]` Source holding account owned by the timelock that will has the actual tokens in escrow. -/// 6. `[writable]` Initialized Yes Voting dump account owned by timelock set to which to send your voting tokens. -/// 7. `[writable]` Initialized No Voting dump account owned by timelock set to which to send your voting tokens. +/// 5. `[writable]` Source holding account owned by the Governance that will has the actual tokens in escrow. /// 8. `[writable]` Voting mint account. /// 9. `[writable]` Yes Voting mint account. /// 10. `[writable]` No Voting mint account. -/// 11. `[]` Timelock state account. -/// 12. `[]` Timelock set account. +/// 11. `[]` Proposal state account. +/// 12. `[]` Proposal account. /// 13. `[]` Transfer authority -/// 14. `[]` Timelock program mint authority +/// 14. `[]` Governance program mint authority (pda of seed Proposal key) /// 15. `[]` Token program account. export const withdrawVotingTokensInstruction = ( governanceVotingRecord: PublicKey, @@ -29,13 +30,11 @@ export const withdrawVotingTokensInstruction = ( noVotingAccount: PublicKey, destinationAccount: PublicKey, sourceHoldingAccount: PublicKey, - yesVotingDump: PublicKey, - noVotingDump: PublicKey, votingMint: PublicKey, yesVotingMint: PublicKey, noVotingMint: PublicKey, - timelockStateAccount: PublicKey, - timelockSetAccount: PublicKey, + proposalStateAccount: PublicKey, + proposalAccount: PublicKey, transferAuthority: PublicKey, mintAuthority: PublicKey, votingTokenAmount: number, @@ -51,7 +50,7 @@ export const withdrawVotingTokensInstruction = ( dataLayout.encode( { - instruction: TimelockInstruction.WithdrawVotingTokens, + instruction: GovernanceInstruction.WithdrawVotingTokens, votingTokenAmount: new BN(votingTokenAmount), }, data, @@ -64,13 +63,11 @@ export const withdrawVotingTokensInstruction = ( { pubkey: noVotingAccount, isSigner: false, isWritable: true }, { pubkey: destinationAccount, isSigner: false, isWritable: true }, { pubkey: sourceHoldingAccount, isSigner: false, isWritable: true }, - { pubkey: yesVotingDump, isSigner: false, isWritable: true }, - { pubkey: noVotingDump, isSigner: false, isWritable: true }, { pubkey: votingMint, isSigner: false, isWritable: true }, { pubkey: yesVotingMint, isSigner: false, isWritable: true }, { pubkey: noVotingMint, isSigner: false, isWritable: true }, - { pubkey: timelockStateAccount, isSigner: false, isWritable: false }, - { pubkey: timelockSetAccount, isSigner: false, isWritable: false }, + { pubkey: proposalStateAccount, isSigner: false, isWritable: false }, + { pubkey: proposalAccount, isSigner: false, isWritable: false }, { pubkey: transferAuthority, isSigner: true, isWritable: false }, { pubkey: mintAuthority, isSigner: false, isWritable: false }, { pubkey: PROGRAM_IDS.token, isSigner: false, isWritable: false }, @@ -78,7 +75,7 @@ export const withdrawVotingTokensInstruction = ( return new TransactionInstruction({ keys, - programId: PROGRAM_IDS.timelock.programId, + programId: PROGRAM_IDS.governance.programId, data, }); }; diff --git a/packages/proposals/src/react-app-env.d.ts b/packages/governance/src/react-app-env.d.ts similarity index 100% rename from packages/proposals/src/react-app-env.d.ts rename to packages/governance/src/react-app-env.d.ts diff --git a/packages/proposals/src/routes.tsx b/packages/governance/src/routes.tsx similarity index 100% rename from packages/proposals/src/routes.tsx rename to packages/governance/src/routes.tsx diff --git a/packages/proposals/src/serviceWorker.ts b/packages/governance/src/serviceWorker.ts similarity index 100% rename from packages/proposals/src/serviceWorker.ts rename to packages/governance/src/serviceWorker.ts diff --git a/packages/proposals/src/setupTests.ts b/packages/governance/src/setupTests.ts similarity index 100% rename from packages/proposals/src/setupTests.ts rename to packages/governance/src/setupTests.ts diff --git a/packages/proposals/src/types/buffer-layout.d.ts b/packages/governance/src/types/buffer-layout.d.ts similarity index 100% rename from packages/proposals/src/types/buffer-layout.d.ts rename to packages/governance/src/types/buffer-layout.d.ts diff --git a/packages/proposals/src/types/sol-wallet-adapter.d.ts b/packages/governance/src/types/sol-wallet-adapter.d.ts similarity index 100% rename from packages/proposals/src/types/sol-wallet-adapter.d.ts rename to packages/governance/src/types/sol-wallet-adapter.d.ts diff --git a/packages/proposals/src/utils/layout.ts b/packages/governance/src/utils/layout.ts similarity index 100% rename from packages/proposals/src/utils/layout.ts rename to packages/governance/src/utils/layout.ts diff --git a/packages/proposals/src/utils/lookups.ts b/packages/governance/src/utils/lookups.ts similarity index 89% rename from packages/proposals/src/utils/lookups.ts rename to packages/governance/src/utils/lookups.ts index 3e06742..3374961 100644 --- a/packages/proposals/src/utils/lookups.ts +++ b/packages/governance/src/utils/lookups.ts @@ -5,7 +5,7 @@ import { GovernanceVotingRecord, GovernanceVotingRecordLayout, GovernanceVotingRecordParser, -} from '../models/timelock'; +} from '../models/governance'; const MAX_LOOKUPS = 5000; export async function getGovernanceVotingRecords( @@ -25,15 +25,15 @@ export async function getGovernanceVotingRecords( id: 1, method: 'getProgramAccounts', params: [ - PROGRAM_IDS.timelock.programId.toBase58(), + PROGRAM_IDS.governance.programId.toBase58(), { commitment: 'single', filters: [ { dataSize: GovernanceVotingRecordLayout.span }, { memcmp: { - // Proposal key is first thing in the account data - offset: 0, + // Proposal key is second thing in the account data + offset: 1, bytes: proposal.toString(), }, }, diff --git a/packages/proposals/src/utils/serialize.ts b/packages/governance/src/utils/serialize.ts similarity index 82% rename from packages/proposals/src/utils/serialize.ts rename to packages/governance/src/utils/serialize.ts index d1dc853..9fefc8c 100644 --- a/packages/proposals/src/utils/serialize.ts +++ b/packages/governance/src/utils/serialize.ts @@ -6,7 +6,7 @@ import { PublicKey, Message, } from '@solana/web3.js'; -import { TimelockSet } from '../models/timelock'; +import { GOVERNANCE_AUTHORITY_SEED, Proposal } from '../models/governance'; export async function serializeInstruction({ connection, instr, @@ -14,7 +14,7 @@ export async function serializeInstruction({ }: { connection: Connection; instr: TransactionInstruction; - proposal: ParsedAccount; + proposal: ParsedAccount; }): Promise<{ base64: string; byteArray: Uint8Array }> { const PROGRAM_IDS = utils.programIds(); let instructionTransaction = new Transaction(); @@ -23,8 +23,8 @@ export async function serializeInstruction({ await connection.getRecentBlockhash('max') ).blockhash; const [authority] = await PublicKey.findProgramAddress( - [proposal.pubkey.toBuffer()], - PROGRAM_IDS.timelock.programId, + [Buffer.from(GOVERNANCE_AUTHORITY_SEED), proposal.pubkey.toBuffer()], + PROGRAM_IDS.governance.programId, ); instructionTransaction.setSigners(authority); const msg: Message = instructionTransaction.compileMessage(); diff --git a/packages/proposals/src/actions/execute.ts b/packages/governance/src/utils/transactions.ts similarity index 57% rename from packages/proposals/src/actions/execute.ts rename to packages/governance/src/utils/transactions.ts index e48a180..3c10584 100644 --- a/packages/proposals/src/actions/execute.ts +++ b/packages/governance/src/utils/transactions.ts @@ -1,76 +1,6 @@ -import { - Account, - Connection, - Message, - PublicKey, - TransactionInstruction, -} from '@solana/web3.js'; -import { contexts, utils, ParsedAccount } from '@oyster/common'; +import { Message, PublicKey } from '@solana/web3.js'; -import { - TimelockSet, - TimelockState, - TimelockTransaction, -} from '../models/timelock'; -import { executeInstruction } from '../models/execute'; -import { LABELS } from '../constants'; -const { sendTransaction } = contexts.Connection; -const { notify } = utils; - -export const execute = async ( - connection: Connection, - wallet: any, - proposal: ParsedAccount, - state: ParsedAccount, - transaction: ParsedAccount, -) => { - let signers: Account[] = []; - let instructions: TransactionInstruction[] = []; - const actualMessage = decodeBufferIntoMessage(transaction.info.instruction); - const accountInfos = getAccountInfos(actualMessage); - - instructions.push( - executeInstruction( - transaction.pubkey, - state.pubkey, - proposal.pubkey, - actualMessage.accountKeys[actualMessage.instructions[0].programIdIndex], - proposal.info.config, - accountInfos, - ), - ); - - notify({ - message: LABELS.EXECUTING, - description: LABELS.PLEASE_WAIT, - type: 'warn', - }); - - try { - let tx = await sendTransaction( - connection, - wallet, - instructions, - signers, - true, - ); - - notify({ - message: LABELS.EXECUTED, - type: 'success', - description: LABELS.TRANSACTION + ` ${tx}`, - }); - } catch (ex) { - console.error(ex); - throw new Error(); - } -}; - -function decodeBufferIntoMessage(instruction: number[]): Message { - return Message.from(instruction); -} - -function getAccountInfos( +export function getMessageAccountInfos( actualMessage: Message, ): { pubkey: PublicKey; isSigner: boolean; isWritable: boolean }[] { console.log(actualMessage); diff --git a/packages/proposals/src/views/dashboard/index.tsx b/packages/governance/src/views/dashboard/index.tsx similarity index 93% rename from packages/proposals/src/views/dashboard/index.tsx rename to packages/governance/src/views/dashboard/index.tsx index 5bd00dc..e55a8e8 100644 --- a/packages/proposals/src/views/dashboard/index.tsx +++ b/packages/governance/src/views/dashboard/index.tsx @@ -4,7 +4,7 @@ import { GUTTER } from '../../constants'; import { contexts, hooks, ParsedAccount } from '@oyster/common'; import './style.less'; import { useProposals } from '../../contexts/proposals'; -import { TimelockSet } from '../../models/timelock'; +import { Proposal } from '../../models/governance'; import { Connection } from '@solana/web3.js'; import { WalletAdapter } from '@solana/wallet-base'; const { useWallet } = contexts.Wallet; @@ -38,7 +38,7 @@ function InnerDummyView({ }: { connection: Connection; wallet: WalletAdapter; - proposal: ParsedAccount; + proposal: ParsedAccount; }) { const sigAccount = useAccountByMint(proposal.info.signatoryMint); if (!sigAccount) return ; diff --git a/packages/proposals/src/views/dashboard/style.less b/packages/governance/src/views/dashboard/style.less similarity index 100% rename from packages/proposals/src/views/dashboard/style.less rename to packages/governance/src/views/dashboard/style.less diff --git a/packages/proposals/src/views/governance/index.tsx b/packages/governance/src/views/governance/index.tsx similarity index 69% rename from packages/proposals/src/views/governance/index.tsx rename to packages/governance/src/views/governance/index.tsx index aad66ee..004e1f9 100644 --- a/packages/proposals/src/views/governance/index.tsx +++ b/packages/governance/src/views/governance/index.tsx @@ -4,20 +4,12 @@ import { LABELS } from '../../constants'; import { hooks, - contexts, useWallet, useConnection, deserializeMint, ParsedAccount, } from '@oyster/common'; -import { - ConsensusAlgorithm, - ExecutionType, - TimelockConfig, - TimelockType, - VotingEntryRule, - ZERO_KEY, -} from '../../models/timelock'; +import { Governance } from '../../models/governance'; import { PublicKey } from '@solana/web3.js'; import { Table } from 'antd'; import MintSourceTokens from '../../components/Proposal/MintSourceTokens'; @@ -30,29 +22,12 @@ const columns = [ key: 'name', }, { - title: LABELS.CONSENSUS_ALGORITHM, - dataIndex: 'consensusAlgorithm', - key: 'consensusAlgorithm', - render: (number: number) => {ConsensusAlgorithm[number]}, - }, - { - title: LABELS.EXECUTION_TYPE, - dataIndex: 'executionType', - key: 'executionType', - render: (number: number) => {ExecutionType[number]}, - }, - { - title: LABELS.PROPOSAL_TYPE, - dataIndex: 'timelockType', - key: 'timelockType', - render: (number: number) => {TimelockType[number]}, - }, - { - title: LABELS.VOTING_ENTRY_RULES, - dataIndex: 'votingEntryRule', - key: 'votingEntryRule', - render: (number: number) => {VotingEntryRule[number]}, + title: LABELS.VOTE_PERCENT_THRESHOLD, + dataIndex: 'voteThreshold', + key: 'voteThreshold', + render: (number: number) => {number}, }, + { title: LABELS.MINIMUM_SLOT_WAITING_PERIOD, dataIndex: 'minimumSlotWaitingPeriod', @@ -75,10 +50,10 @@ const columns = [ title: LABELS.COUNCIL_MINT, dataIndex: 'councilMint', key: 'councilMint', - render: (key: PublicKey) => {key.toBase58()}, + render: (key: PublicKey) => {key?.toBase58()}, }, { - title: LABELS.PROGRAM, + title: LABELS.PROGRAM_ID, dataIndex: 'program', key: 'program', render: (key: PublicKey) => {key.toBase58()}, @@ -88,11 +63,11 @@ const columns = [ title: LABELS.ACTIONS, dataIndex: 'config', key: 'config', - render: (config: ParsedAccount) => ( + render: (config: ParsedAccount) => ( <> - - {config.info.councilMint.toBase58() != ZERO_KEY && ( - + + {config.info.councilMint && ( + )} ), @@ -136,7 +111,7 @@ export const GovernanceDashboard = () => { })), ); }); - }, [configs.length, myTokenAccts.join(',')]); + }, [configs.length, myTokenAccts.join(',')]); //eslint-disable-line return
; }; diff --git a/packages/proposals/src/views/governance/register.tsx b/packages/governance/src/views/governance/register.tsx similarity index 65% rename from packages/proposals/src/views/governance/register.tsx rename to packages/governance/src/views/governance/register.tsx index c25fb39..3c8e2c8 100644 --- a/packages/proposals/src/views/governance/register.tsx +++ b/packages/governance/src/views/governance/register.tsx @@ -1,15 +1,8 @@ import React, { useState } from 'react'; -import { Button, ButtonProps, Modal, Switch } from 'antd'; -import { Form, Input, Select } from 'antd'; +import { Button, ButtonProps, InputNumber, Modal, Switch } from 'antd'; +import { Form, Input } from 'antd'; import { PublicKey } from '@solana/web3.js'; -import { - CONFIG_NAME_LENGTH, - ConsensusAlgorithm, - ExecutionType, - TimelockType, - VotingEntryRule, - ZERO_KEY, -} from '../../models/timelock'; +import { GOVERNANCE_NAME_LENGTH } from '../../models/governance'; import { LABELS } from '../../constants'; import { contexts, utils, tryParseKey } from '@oyster/common'; import { registerProgramGovernance } from '../../actions/registerProgramGovernance'; @@ -18,7 +11,6 @@ import BN from 'bn.js'; const { useWallet } = contexts.Wallet; const { useConnection } = contexts.Connection; -const { Option } = Select; const { notify } = utils; const layout = { @@ -70,10 +62,8 @@ export function NewForm({ const wallet = useWallet(); const connection = useConnection(); const onFinish = async (values: { - timelockType: TimelockType; - executionType: ExecutionType; - consensusAlgorithm: ConsensusAlgorithm; - votingEntryRule: VotingEntryRule; + voteThreshold: number; + minimumSlotWaitingPeriod: string; timeLimit: string; governanceMint: string; @@ -121,20 +111,17 @@ export function NewForm({ return; } - const uninitializedConfig = { - timelockType: values.timelockType, - executionType: values.executionType, - consensusAlgorithm: values.consensusAlgorithm, - votingEntryRule: values.votingEntryRule, + const uninitializedGovernance = { + voteThreshold: values.voteThreshold, + minimumSlotWaitingPeriod: new BN(values.minimumSlotWaitingPeriod), governanceMint: values.governanceMint ? new PublicKey(values.governanceMint) : undefined, councilMint: values.councilMint ? new PublicKey(values.councilMint) - : councilVisible - ? undefined // if visible but empty, set undefined so we instantiate one - : new PublicKey(ZERO_KEY), // default empty case, just make it padding since user doesnt want one. + : undefined, + program: new PublicKey(values.program), name: values.name, timeLimit: new BN(values.timeLimit), @@ -143,7 +130,8 @@ export function NewForm({ const newConfig = await registerProgramGovernance( connection, wallet.wallet, - uninitializedConfig, + uninitializedGovernance, + councilVisible, ); handleOk(newConfig); }; @@ -156,11 +144,11 @@ export function NewForm({ >
- + @@ -199,52 +187,12 @@ export function NewForm({ - - - - - - - - - - + diff --git a/packages/proposals/src/views/home/index.tsx b/packages/governance/src/views/home/index.tsx similarity index 91% rename from packages/proposals/src/views/home/index.tsx rename to packages/governance/src/views/home/index.tsx index 6c26c91..153ddd1 100644 --- a/packages/proposals/src/views/home/index.tsx +++ b/packages/governance/src/views/home/index.tsx @@ -6,7 +6,7 @@ import { TokenIcon, useWallet } from '@oyster/common'; import { Background } from './../../components/Background'; import { useHistory } from 'react-router-dom'; import { RegisterGovernanceMenuItem } from '../governance/register'; -import { TimelockStateStatus } from '../../models/timelock'; +import { ProposalStateStatus } from '../../models/governance'; export const HomeView = () => { const history = useHistory(); @@ -23,11 +23,11 @@ export const HomeView = () => { (acc, proposalKey) => { let proposal = proposals[proposalKey]; let state = states[proposal.info.state.toBase58()]; - if (proposal.info.config.toBase58() == configKey) { + if (proposal.info.config.toBase58() === configKey) { acc.active = acc.active + - (state.info.status === TimelockStateStatus.Voting || - state.info.status === TimelockStateStatus.Draft + (state.info.status === ProposalStateStatus.Voting || + state.info.status === ProposalStateStatus.Draft ? 1 : 0); @@ -56,7 +56,7 @@ export const HomeView = () => { }); }); return newListData; - }, [configs, proposals]); + }, [configs, proposals, states]); return ( <> diff --git a/packages/proposals/src/views/home/style.less b/packages/governance/src/views/home/style.less similarity index 100% rename from packages/proposals/src/views/home/style.less rename to packages/governance/src/views/home/style.less diff --git a/packages/proposals/src/views/index.tsx b/packages/governance/src/views/index.tsx similarity index 100% rename from packages/proposals/src/views/index.tsx rename to packages/governance/src/views/index.tsx diff --git a/packages/proposals/src/views/proposal/index.tsx b/packages/governance/src/views/proposal/index.tsx similarity index 79% rename from packages/proposals/src/views/proposal/index.tsx rename to packages/governance/src/views/proposal/index.tsx index dfb6434..710ebfe 100644 --- a/packages/proposals/src/views/proposal/index.tsx +++ b/packages/governance/src/views/proposal/index.tsx @@ -1,16 +1,15 @@ -import { Card, Col, Grid, Row, Spin, Statistic, Tabs } from 'antd'; +import { Card, Col, Row, Spin, Statistic, Tabs } from 'antd'; import React, { useMemo, useState } from 'react'; import { LABELS } from '../../constants'; import { ParsedAccount, TokenIcon } from '@oyster/common'; import { - ConsensusAlgorithm, INSTRUCTION_LIMIT, - TimelockConfig, - TimelockSet, - TimelockState, - TimelockStateStatus, - TimelockTransaction, -} from '../../models/timelock'; + Governance, + Proposal, + ProposalState, + ProposalStateStatus, + GovernanceTransaction, +} from '../../models/governance'; import { useParams } from 'react-router-dom'; import ReactMarkdown from 'react-markdown'; import { useProposals } from '../../contexts/proposals'; @@ -31,11 +30,12 @@ import { VoterBubbleGraph } from '../../components/Proposal/VoterBubbleGraph'; import { VoterTable } from '../../components/Proposal/VoterTable'; const { TabPane } = Tabs; +// eslint-disable-next-line export const urlRegex = /[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/; const { useMint } = contexts.Accounts; const { useConnectionConfig } = contexts.Connection; const { useAccountByMint } = hooks; -const { useBreakpoint } = Grid; +//const { useBreakpoint } = Grid; export enum VoteType { Undecided = 'Undecided', @@ -47,8 +47,8 @@ export const ProposalView = () => { const context = useProposals(); const { id } = useParams<{ id: string }>(); const proposal = context.proposals[id]; - const timelockConfig = context.configs[proposal?.info.config.toBase58()]; - const timelockState = context.states[proposal?.info.state.toBase58()]; + const governance = context.configs[proposal?.info.config.toBase58()]; + const proposalState = context.states[proposal?.info.state.toBase58()]; const { endpoint } = useConnectionConfig(); const sigMint = useMint(proposal?.info.signatoryMint); const votingMint = useMint(proposal?.info.votingMint); @@ -69,8 +69,8 @@ export const ProposalView = () => { noVotingMint ? ( void; @@ -102,11 +102,11 @@ function useLoadGist({ setFailed: (b: boolean) => void; setContent: (b: string) => void; isGist: boolean; - timelockState: ParsedAccount; + proposalState: ParsedAccount; }) { useMemo(() => { if (loading) { - let toFetch = timelockState.info.descLink; + let toFetch = proposalState.info.descLink; const pieces = toFetch.match(urlRegex); if (isGist && pieces) { const justIdWithoutUser = pieces[1].split('/')[2]; @@ -114,7 +114,7 @@ function useLoadGist({ } fetch(toFetch) .then(async resp => { - if (resp.status == 200) { + if (resp.status === 200) { if (isGist) { const jsonContent = await resp.json(); const nextUrlFileName = Object.keys(jsonContent['files'])[0]; @@ -124,7 +124,7 @@ function useLoadGist({ ); } else setContent(await resp.text()); } else { - if (resp.status == 403 && isGist) + if (resp.status === 403 && isGist) setMsg(LABELS.GIT_CONTENT_EXCEEDED); setFailed(true); } @@ -135,7 +135,7 @@ function useLoadGist({ setLoading(false); }); } - }, [loading]); + }, [loading]); //eslint-disable-line } interface PartialGovernanceRecord { info: { yesCount: BN; noCount: BN; undecidedCount: BN }; @@ -156,6 +156,7 @@ function voterDisplayData( title: key, group: label, value: amount, + key: key, }); const undecidedData = [ @@ -199,51 +200,52 @@ function voterDisplayData( const data = [...undecidedData, ...yesData, ...noData].sort( (a, b) => b.value - a.value, ); + return data; } function InnerProposalView({ proposal, - timelockState, + proposalState, sigMint, votingMint, yesVotingMint, noVotingMint, instructions, - timelockConfig, + governance, sourceMint, votingDisplayData, endpoint, }: { - proposal: ParsedAccount; - timelockConfig: ParsedAccount; - timelockState: ParsedAccount; + proposal: ParsedAccount; + governance: ParsedAccount; + proposalState: ParsedAccount; sigMint: MintInfo; votingMint: MintInfo; yesVotingMint: MintInfo; noVotingMint: MintInfo; sourceMint: MintInfo; - instructions: Record>; + instructions: Record>; votingDisplayData: Array; endpoint: string; }) { const sigAccount = useAccountByMint(proposal.info.signatoryMint); const adminAccount = useAccountByMint(proposal.info.adminMint); - const instructionsForProposal: ParsedAccount[] = timelockState.info.timelockTransactions + const instructionsForProposal: ParsedAccount[] = proposalState.info.proposalTransactions .map(k => instructions[k.toBase58()]) .filter(k => k); - const isUrl = !!timelockState.info.descLink.match(urlRegex); + const isUrl = !!proposalState.info.descLink.match(urlRegex); const isGist = - !!timelockState.info.descLink.match(/gist/i) && - !!timelockState.info.descLink.match(/github/i); - const [content, setContent] = useState(timelockState.info.descLink); + !!proposalState.info.descLink.match(/gist/i) && + !!proposalState.info.descLink.match(/github/i); + const [content, setContent] = useState(proposalState.info.descLink); const [loading, setLoading] = useState(isUrl); const [failed, setFailed] = useState(false); const [msg, setMsg] = useState(''); const [width, setWidth] = useState(); const [height, setHeight] = useState(); - const breakpoint = useBreakpoint(); + // const breakpoint = useBreakpoint(); useLoadGist({ loading, @@ -252,7 +254,7 @@ function InnerProposalView({ setMsg, setContent, isGist, - timelockState, + proposalState: proposalState, }); return ( @@ -266,8 +268,8 @@ function InnerProposalView({ size={60} />
-

{timelockState.info.name}

- +

{proposalState.info.name}

+ @@ -275,36 +277,32 @@ function InnerProposalView({
{adminAccount && adminAccount.info.amount.toNumber() === 1 && - timelockState.info.status === TimelockStateStatus.Draft && ( - + proposalState.info.status === ProposalStateStatus.Draft && ( + )} {sigAccount && sigAccount.info.amount.toNumber() === 1 && - timelockState.info.status === TimelockStateStatus.Draft && ( - + proposalState.info.status === ProposalStateStatus.Draft && ( + )} - +
@@ -368,10 +366,10 @@ function InnerProposalView({ @@ -389,7 +387,7 @@ function InnerProposalView({ @@ -409,7 +407,11 @@ function InnerProposalView({ failed ? (

{LABELS.DESCRIPTION}:{' '} - + {msg ? msg : LABELS.NO_LOAD}

@@ -433,17 +435,17 @@ function InnerProposalView({ proposal={proposal} position={position + 1} instruction={instruction} - state={timelockState} + state={proposalState} /> ))} {instructionsForProposal.length < INSTRUCTION_LIMIT && - timelockState.info.status === TimelockStateStatus.Draft && ( + proposalState.info.status === ProposalStateStatus.Draft && ( @@ -459,19 +461,12 @@ function InnerProposalView({ } function getVotesRequired( - timelockConfig: ParsedAccount, + governance: ParsedAccount, sourceMint: MintInfo, ): number { - if (timelockConfig.info.consensusAlgorithm === ConsensusAlgorithm.Majority) { - return Math.ceil(sourceMint.supply.toNumber() * 0.5); - } else if ( - timelockConfig.info.consensusAlgorithm === ConsensusAlgorithm.SuperMajority - ) { - return Math.ceil(sourceMint.supply.toNumber() * 0.66); - } else if ( - timelockConfig.info.consensusAlgorithm === ConsensusAlgorithm.FullConsensus - ) { - return sourceMint.supply.toNumber(); - } - return 0; + return governance.info.voteThreshold === 100 + ? sourceMint.supply.toNumber() + : Math.ceil( + (governance.info.voteThreshold / 100) * sourceMint.supply.toNumber(), + ); } diff --git a/packages/proposals/src/views/proposal/new.tsx b/packages/governance/src/views/proposal/new.tsx similarity index 91% rename from packages/proposals/src/views/proposal/new.tsx rename to packages/governance/src/views/proposal/new.tsx index 15d6e77..6e6b118 100644 --- a/packages/proposals/src/views/proposal/new.tsx +++ b/packages/governance/src/views/proposal/new.tsx @@ -2,7 +2,7 @@ import React, { useState } from 'react'; import { Button, ButtonProps, Modal, Radio } from 'antd'; import { Form, Input, Select } from 'antd'; import { Account } from '@solana/web3.js'; -import { DESC_SIZE, NAME_SIZE, ZERO_KEY } from '../../models/timelock'; +import { DESC_SIZE, NAME_SIZE } from '../../models/governance'; import { LABELS } from '../../constants'; import { contexts, utils } from '@oyster/common'; import { createProposal } from '../../actions/createProposal'; @@ -74,13 +74,13 @@ export function NewForm({ name: string; proposalMintType: string; description: string; - timelockConfigKey: string; + governanceKey: string; }) => { - const config = context.configs[values.timelockConfigKey]; + const config = context.configs[values.governanceKey]; if ( values.proposalMintType === ProposalMintType.Council && - config.info.councilMint.toBase58() === ZERO_KEY + !config.info.councilMint ) { notify({ message: LABELS.THIS_CONFIG_LACKS_COUNCIL, @@ -132,13 +132,15 @@ export function NewForm({ diff --git a/packages/proposals/src/views/proposal/style.less b/packages/governance/src/views/proposal/style.less similarity index 100% rename from packages/proposals/src/views/proposal/style.less rename to packages/governance/src/views/proposal/style.less diff --git a/packages/proposals/src/views/proposals/index.tsx b/packages/governance/src/views/proposals/index.tsx similarity index 92% rename from packages/proposals/src/views/proposals/index.tsx rename to packages/governance/src/views/proposals/index.tsx index d79343e..2b7d06c 100644 --- a/packages/proposals/src/views/proposals/index.tsx +++ b/packages/governance/src/views/proposals/index.tsx @@ -13,7 +13,7 @@ export const ProposalsView = () => { const history = useHistory(); const { proposals, states } = useProposals(); const config = useConfig(id); - const [page, setPage] = useState(0); + const [, setPage] = useState(0); const { tokenMap } = useConnectionConfig(); const { connected } = useWallet(); const token = tokenMap.get( @@ -41,10 +41,11 @@ export const ProposalsView = () => { badge: , status: state.info.status, state, + key, }); }); return newListData; - }, [proposals]); + }, [proposals, id, mint, states]); return ( { /> @@ -87,7 +92,7 @@ export const ProposalsView = () => { dataSource={listData} renderItem={item => ( history.push(item.href)} > diff --git a/packages/proposals/src/views/proposals/style.less b/packages/governance/src/views/proposals/style.less similarity index 100% rename from packages/proposals/src/views/proposals/style.less rename to packages/governance/src/views/proposals/style.less diff --git a/packages/proposals/src/wdyr.ts b/packages/governance/src/wdyr.ts similarity index 84% rename from packages/proposals/src/wdyr.ts rename to packages/governance/src/wdyr.ts index 83c7d54..cbe0b1c 100644 --- a/packages/proposals/src/wdyr.ts +++ b/packages/governance/src/wdyr.ts @@ -3,6 +3,6 @@ import React from 'react'; if (process.env.NODE_ENV === 'development') { const whyDidYouRender = require('@welldone-software/why-did-you-render'); whyDidYouRender(React, { - trackAllPureComponents: true, + trackAllPureComponents: false, }); } diff --git a/packages/proposals/tsconfig.json b/packages/governance/tsconfig.json similarity index 100% rename from packages/proposals/tsconfig.json rename to packages/governance/tsconfig.json diff --git a/packages/proposals/types/buffer-layout.d.ts b/packages/governance/types/buffer-layout.d.ts similarity index 100% rename from packages/proposals/types/buffer-layout.d.ts rename to packages/governance/types/buffer-layout.d.ts diff --git a/packages/lending/package.json b/packages/lending/package.json index af935de..4b3af8b 100644 --- a/packages/lending/package.json +++ b/packages/lending/package.json @@ -3,6 +3,7 @@ "version": "0.1.0", "dependencies": { "@solana/wallet-base": "0.0.1", + "@solana/wallet-ledger": "0.0.1", "@ant-design/icons": "^4.4.0", "@ant-design/pro-layout": "^6.7.0", "@babel/preset-typescript": "^7.12.13", @@ -12,7 +13,7 @@ "@project-serum/sol-wallet-adapter": "^0.1.4", "@solana/spl-token": "0.0.13", "@solana/spl-token-swap": "0.1.0", - "@solana/web3.js": "^0.86.2", + "@solana/web3.js": "^1.5.0", "@testing-library/jest-dom": "^4.2.4", "@testing-library/react": "^9.5.0", "@testing-library/user-event": "^7.2.1", diff --git a/packages/lending/src/App.less b/packages/lending/src/App.less index 60f457c..ff8e483 100644 --- a/packages/lending/src/App.less +++ b/packages/lending/src/App.less @@ -105,22 +105,6 @@ em { display: flex; } -.wallet-wrapper { - padding-left: 0.7rem; - border-radius: 0.5rem; - display: flex; - align-items: center; - white-space: nowrap; -} - -.wallet-key { - padding: 0.1rem 0.5rem 0.1rem 0.7rem; - margin-left: 0.3rem; - border-radius: 0.5rem; - display: flex; - align-items: center; -} - .flash-positive { color: rgba(0, 255, 0, 0.6); } diff --git a/packages/lending/src/contexts/lending.tsx b/packages/lending/src/contexts/lending.tsx index d9f7b47..787d4f7 100644 --- a/packages/lending/src/contexts/lending.tsx +++ b/packages/lending/src/contexts/lending.tsx @@ -144,9 +144,11 @@ export const useLending = () => { const subID = connection.onProgramAccountChange( LENDING_PROGRAM_ID, async info => { - const id = (info.accountId as unknown) as string; + const pubkey = typeof info.accountId === 'string' ? + new PublicKey((info.accountId as unknown) as string) : + info.accountId; const item = { - pubkey: new PublicKey(id), + pubkey, account: info.accountInfo, }; processAccount(item); diff --git a/packages/lending/src/utils/pools.ts b/packages/lending/src/utils/pools.ts index f442cff..cad88b5 100644 --- a/packages/lending/src/utils/pools.ts +++ b/packages/lending/src/utils/pools.ts @@ -153,13 +153,18 @@ export const usePools = () => { const subID = connection.onProgramAccountChange( programIds().swap, async info => { - const id = (info.accountId as unknown) as string; + const pubkey = + typeof info.accountId === 'string' + ? new PublicKey((info.accountId as unknown) as string) + : info.accountId; + const id = pubkey.toBase58(); + if (info.accountInfo.data.length === programIds().swapLayout.span) { const account = info.accountInfo; const updated = { data: programIds().swapLayout.decode(account.data), account: account, - pubkey: new PublicKey(id), + pubkey, }; const index = diff --git a/packages/lending/src/views/reserve/index.tsx b/packages/lending/src/views/reserve/index.tsx index be8cccb..820aac3 100644 --- a/packages/lending/src/views/reserve/index.tsx +++ b/packages/lending/src/views/reserve/index.tsx @@ -2,7 +2,6 @@ import { Col, Row } from 'antd'; import React from 'react'; import { useParams } from 'react-router-dom'; import { ReserveStatus } from '../../components/ReserveStatus'; - import { UserLendingCard } from '../../components/UserLendingCard'; import { GUTTER } from '../../constants'; import { useLendingReserve } from '../../hooks'; diff --git a/packages/metavinci/.env.production b/packages/metavinci/.env.production new file mode 100644 index 0000000..668046e --- /dev/null +++ b/packages/metavinci/.env.production @@ -0,0 +1 @@ +GENERATE_SOURCEMAP = false diff --git a/packages/metavinci/.gitignore b/packages/metavinci/.gitignore new file mode 100644 index 0000000..ea2b4f5 --- /dev/null +++ b/packages/metavinci/.gitignore @@ -0,0 +1,2 @@ +.env +target diff --git a/packages/metavinci/_colors.less b/packages/metavinci/_colors.less new file mode 100644 index 0000000..b40026c --- /dev/null +++ b/packages/metavinci/_colors.less @@ -0,0 +1,5 @@ +@surge-20: #00CC82; +@tungsten-100: #06101a; +@tungsten-60: #547595; +@tungsten-50: #0D1B28; +@tungsten-40: #7BA4C7; diff --git a/packages/metavinci/craco.config.js b/packages/metavinci/craco.config.js new file mode 100644 index 0000000..1520df6 --- /dev/null +++ b/packages/metavinci/craco.config.js @@ -0,0 +1,58 @@ +const CracoLessPlugin = require('craco-less'); +const CracoAlias = require('craco-alias'); +const CracoBabelLoader = require('craco-babel-loader'); +const path = require('path'); +const fs = require('fs'); + +//console.log('qualified', pnp.resolveRequest('@babel/preset-typescript'), path.resolve(__dirname, '/') + 'src/'); + +// Handle relative paths to sibling packages +const appDirectory = fs.realpathSync(process.cwd()); +const resolvePackage = relativePath => path.resolve(appDirectory, relativePath); + +module.exports = { + webpack: { + configure: (webpackConfig, { env, paths }) => { + paths.appBuild = webpackConfig.output.path = path.resolve( + './../../build/metavinci', + ); + return webpackConfig; + }, + }, + plugins: [ + /*{ + plugin: CracoBabelLoader, + options: { + includes: [ + // No "unexpected token" error importing components from these lerna siblings: + resolvePackage('../packages'), + ], + }, + },*/ + /*{ + plugin: CracoAlias, + options: { + source: 'tsconfig', + // baseUrl SHOULD be specified + // plugin does not take it from tsconfig + baseUrl: '../../', + // tsConfigPath should point to the file where "baseUrl" and "paths" are specified + tsConfigPath: '../../tsconfig.json', + }, + },*/ + { + plugin: CracoLessPlugin, + options: { + lessLoaderOptions: { + lessOptions: { + modifyVars: { + '@primary-color': '#768BF9', + '@text-color': 'rgba(255, 255, 255)' + }, + javascriptEnabled: true, + }, + }, + }, + }, + ], +}; diff --git a/packages/metavinci/landing/image.png b/packages/metavinci/landing/image.png new file mode 100644 index 0000000..f232ed5 Binary files /dev/null and b/packages/metavinci/landing/image.png differ diff --git a/packages/metavinci/landing/index.html b/packages/metavinci/landing/index.html new file mode 100644 index 0000000..2ca7a6e --- /dev/null +++ b/packages/metavinci/landing/index.html @@ -0,0 +1,49 @@ + + + + + + Metaplex NFT Marketplace + + + + + + + + + + + +
+
METAPLEX
+
+
+
+
NFT platforms. Push to start.
+
+ Metaplex is an open source NFT framework built on Solana that puts creators and artists in the drivers + seat. +
+
+ With Metaplex, you can launch an NFT marketplace in minutes. +
+
+
+ + +
+ +
+
+
+
+
+
+
+ + + diff --git a/packages/metavinci/landing/landing.css b/packages/metavinci/landing/landing.css new file mode 100644 index 0000000..a373246 --- /dev/null +++ b/packages/metavinci/landing/landing.css @@ -0,0 +1,101 @@ + +body { + background-color: black; + font-family: "Inter"; +} + +.header { + font-style: italic; + font-weight: 700; + font-size: 2rem; + line-height: 40px; + + color: #FFFFFF; + border: 1px solid #000000; + +} + +.subheader { + font-style: normal; + font-weight: 500; + font-size: 36px; + line-height: 48px; + + color: #FFFFFF; + margin: 42px 0px; +} + +.text { + font-style: normal; + font-weight: normal; + font-size: 18px; + line-height: 1.5; + + color: rgba(255, 255, 255, 0.7); + +} + +.image { + width: 100%; + height: 100vw; + max-height: 630px; + + background: url(image.png); + background-repeat: no-repeat; + background-size: contain; +} + +/* button { + display: flex; + flex-direction: row; + justify-content: center; + align-items: center; + padding: 20px 10px; + + position: static; + width: 350px; + height: 59px; + left: 0px; + top: 69px; + + background: linear-gradient(270deg, #616774 7.29%, #403F4C 100%); + border-radius: 8px; + + flex: none; + order: 1; + flex-grow: 0; + margin: 15px 0px; + + color: white; +} + +.email-input { + display: flex; + flex-direction: row; + align-items: center; + padding: 16px 10px 16px 24px; + + position: static; + width: 348px; + height: 54px; + left: 0px; + top: 0px; + + background: #282828; + border-radius: 8px; + + flex: none; + order: 0; + flex-grow: 0; + margin: 15px 0px; +} */ + +.typeform-widget { + height: 360px !important; +} + +#form { + width: 100%; + max-width: 400px; + margin-bottom: 50px; +} diff --git a/packages/metavinci/package.json b/packages/metavinci/package.json new file mode 100644 index 0000000..8921fd0 --- /dev/null +++ b/packages/metavinci/package.json @@ -0,0 +1,107 @@ +{ + "name": "metavinci", + "version": "0.1.0", + "dependencies": { + "@ant-design/icons": "^4.4.0", + "@babel/preset-typescript": "^7.12.13", + "@craco/craco": "^5.7.0", + "@oyster/common": "0.0.1", + "@project-serum/serum": "^0.13.11", + "@project-serum/sol-wallet-adapter": "^0.1.4", + "@react-three/drei": "^3.8.0", + "@solana/spl-token": "0.0.13", + "@solana/spl-token-registry": "^0.2.0", + "@solana/spl-token-swap": "0.1.0", + "@solana/wallet-base": "0.0.1", + "@solana/wallet-ledger": "0.0.1", + "@solana/web3.js": "^1.5.0", + "@testing-library/jest-dom": "^4.2.4", + "@testing-library/react": "^9.5.0", + "@testing-library/user-event": "^7.2.1", + "@toruslabs/openlogin": "^0.8.0", + "@toruslabs/openlogin-ed25519": "^0.8.0", + "@toruslabs/openlogin-utils": "^0.8.0", + "@toruslabs/torus-embed": "^1.10.9", + "@types/animejs": "^3.1.3", + "@types/chart.js": "^2.9.29", + "@types/react-router-dom": "^5.1.6", + "@types/react-virtualized": "^9.21.11", + "@types/testing-library__react": "^10.2.0", + "@welldone-software/why-did-you-render": "^6.0.5", + "animejs": "^3.2.1", + "bn.js": "^5.1.3", + "borsh": "^0.3.1", + "bs58": "^4.0.1", + "buffer-layout": "^1.2.0", + "chart.js": "^2.9.4", + "craco-alias": "^2.1.1", + "craco-babel-loader": "^0.1.4", + "craco-less": "^1.17.0", + "eventemitter3": "^4.0.7", + "identicon.js": "^2.3.3", + "jazzicon": "^1.5.0", + "lodash": "^4.17.20", + "react": "16.13.1", + "react-dom": "16.13.1", + "react-github-btn": "^1.2.0", + "react-intl": "^5.10.2", + "react-masonry-css": "^1.0.16", + "react-router-dom": "^5.2.0", + "react-scripts": "3.4.3", + "react-three-fiber": "^5.3.18", + "react-virtualized": "^9.22.3", + "three": "^0.125.2", + "typescript": "^4.1.3", + "use-wallet": "^0.8.1" + }, + "scripts": { + "prestart": "npm-link-shared ../common/node_modules/ . react", + "start": "craco start --verbose", + "build": "craco build", + "test": "craco test", + "eject": "react-scripts eject", + "deploy:ar": "arweave deploy-dir ../../build/metavinci --key-file ", + "deploy": "gh-pages -d ../../build/metavinci --repo https://github.com/solana-labs/oyster-meta", + "format:fix": "prettier --write \"**/*.+(js|jsx|ts|tsx|json|css|md)\"" + }, + "eslintConfig": { + "extends": "react-app" + }, + "browserslist": { + "production": [ + ">0.2%", + "not dead", + "not op_mini all" + ], + "development": [ + "last 1 chrome version", + "last 1 firefox version", + "last 1 safari version" + ] + }, + "repository": { + "type": "git", + "url": "https://github.com/solana-labs/oyster" + }, + "homepage": ".", + "devDependencies": { + "@typechain/ethers-v4": "^1.0.0", + "@types/bn.js": "^5.1.0", + "@types/bs58": "^4.0.1", + "@types/identicon.js": "^2.3.0", + "@types/jest": "^24.9.1", + "@types/node": "^12.12.62", + "arweave-deploy": "^1.9.1", + "gh-pages": "^3.1.0", + "npm-link-shared": "0.5.6", + "prettier": "^2.1.2" + }, + "peerDependencies": { + "react": "*", + "react-dom": "*" + }, + "resolutions": { + "react": "16.13.1", + "react-dom": "16.13.1" + } +} diff --git a/packages/metavinci/public/favicon-16x16.png b/packages/metavinci/public/favicon-16x16.png new file mode 100644 index 0000000..f90c686 Binary files /dev/null and b/packages/metavinci/public/favicon-16x16.png differ diff --git a/packages/metavinci/public/favicon-32x32.png b/packages/metavinci/public/favicon-32x32.png new file mode 100644 index 0000000..0b6246b Binary files /dev/null and b/packages/metavinci/public/favicon-32x32.png differ diff --git a/packages/metavinci/public/favicon-96x96.png b/packages/metavinci/public/favicon-96x96.png new file mode 100644 index 0000000..7c767b1 Binary files /dev/null and b/packages/metavinci/public/favicon-96x96.png differ diff --git a/packages/metavinci/public/img/artist1.jpeg b/packages/metavinci/public/img/artist1.jpeg new file mode 100644 index 0000000..c884b07 Binary files /dev/null and b/packages/metavinci/public/img/artist1.jpeg differ diff --git a/packages/metavinci/public/img/artist2.jpeg b/packages/metavinci/public/img/artist2.jpeg new file mode 100644 index 0000000..bbe3a5f Binary files /dev/null and b/packages/metavinci/public/img/artist2.jpeg differ diff --git a/packages/metavinci/public/img/artist3.jpeg b/packages/metavinci/public/img/artist3.jpeg new file mode 100644 index 0000000..c8c8d21 Binary files /dev/null and b/packages/metavinci/public/img/artist3.jpeg differ diff --git a/packages/metavinci/public/img/artist4.jpeg b/packages/metavinci/public/img/artist4.jpeg new file mode 100644 index 0000000..c13843c Binary files /dev/null and b/packages/metavinci/public/img/artist4.jpeg differ diff --git a/packages/metavinci/public/img/banner1.jpeg b/packages/metavinci/public/img/banner1.jpeg new file mode 100644 index 0000000..cdedc77 Binary files /dev/null and b/packages/metavinci/public/img/banner1.jpeg differ diff --git a/packages/metavinci/public/index.html b/packages/metavinci/public/index.html new file mode 100644 index 0000000..825e6ea --- /dev/null +++ b/packages/metavinci/public/index.html @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + Metaplex NFT Marketplace + + + + + + +
+ + + + + diff --git a/packages/metavinci/public/logo.ico b/packages/metavinci/public/logo.ico new file mode 100644 index 0000000..da48393 Binary files /dev/null and b/packages/metavinci/public/logo.ico differ diff --git a/packages/metavinci/public/manifest.json b/packages/metavinci/public/manifest.json new file mode 100644 index 0000000..7e4b119 --- /dev/null +++ b/packages/metavinci/public/manifest.json @@ -0,0 +1,46 @@ +{ + "short_name": "Metaplex NFT Marketplace", + "name": "Metaplex NFT Marketplace", + "icons": [ + { + "src": "/android-icon-36x36.png", + "sizes": "36x36", + "type": "image/png", + "density": "0.75" + }, + { + "src": "/android-icon-48x48.png", + "sizes": "48x48", + "type": "image/png", + "density": "1.0" + }, + { + "src": "/android-icon-72x72.png", + "sizes": "72x72", + "type": "image/png", + "density": "1.5" + }, + { + "src": "/android-icon-96x96.png", + "sizes": "96x96", + "type": "image/png", + "density": "2.0" + }, + { + "src": "/android-icon-144x144.png", + "sizes": "144x144", + "type": "image/png", + "density": "3.0" + }, + { + "src": "/android-icon-192x192.png", + "sizes": "192x192", + "type": "image/png", + "density": "4.0" + } + ], + "start_url": ".", + "display": "standalone", + "theme_color": "#000000", + "background_color": "#ffffff" +} diff --git a/packages/metavinci/public/robots.txt b/packages/metavinci/public/robots.txt new file mode 100644 index 0000000..e9e57dc --- /dev/null +++ b/packages/metavinci/public/robots.txt @@ -0,0 +1,3 @@ +# https://www.robotstxt.org/robotstxt.html +User-agent: * +Disallow: diff --git a/packages/metavinci/src/App.less b/packages/metavinci/src/App.less new file mode 100644 index 0000000..5ab8775 --- /dev/null +++ b/packages/metavinci/src/App.less @@ -0,0 +1,120 @@ + +@import '~antd/es/style/themes/dark.less'; +@import "~antd/dist/antd.dark.less"; +@import "./ant-custom.less"; + +@solana-green: #00FFA3; + +body { + --row-highlight: @background-color-base; + margin: 0; + + font-style: normal; + font-weight: normal; + font-family: DM Sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', + 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', + sans-serif !important; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.ant-layout { + background: transparent !important; +} + +.App { + background: #101010 !important; + padding: 0px 30px; + + > section { + max-width: 1280px; + + @media (min-width: 600px) { + padding-left: 24px; + padding-right: 24px; + } + } +} + +code { + font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', + monospace; +} + +.app-logo { + background-image: url("data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9JzMwMHB4JyB3aWR0aD0nMzAwcHgnICBmaWxsPSIjZDgzYWViIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2ZXJzaW9uPSIxLjEiIHg9IjBweCIgeT0iMHB4IiB2aWV3Qm94PSIwIDAgMTAwIDEwMCIgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyAwIDAgMTAwIDEwMCIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+PHBhdGggZD0iTTQwLjM2LDUwLjkxYzAuMDA3LTguMTc0LDMuODM2LTExLjUyNSw3LjA0OC0xMi44OThjNi41NTEtMi44MDEsMTYuNzksMC4xNDEsMjMuODA5LDYuODQyICBjMS4yNDYsMS4xODksMi4zNjEsMi4zMDksMy4zNjUsMy4zNjhjLTUuNjg0LTguMzcyLTE1LjAyNS0xNy41NjYtMjkuMDY0LTE4Ljg1OWMtNy43OTQtMC43MTYtMTMuNzk0LDIuNzk5LTE2LjAzMyw5LjQwOCAgYy0yLjY0OSw3LjgyMSwwLjM0MSwxOS4zMDUsMTEuMTgxLDI2LjEyMmM2LjE1MywzLjg2OSwxMi4zLDYuODY5LDE3LjM0MSw5LjA0NWMtMC41NTEtMC4zNTQtMS4xMDUtMC43MTYtMS42Ni0xLjA5MSAgQzQ1LjczMyw2NS42NjIsNDAuMzU0LDU4LjI4MSw0MC4zNiw1MC45MXoiPjwvcGF0aD48cGF0aCBkPSJNNjAuMDI3LDYzLjc2MWMtMC4wNzgtNC43MTUsMS44OTgtOC4yNSw1LjQyMi05LjY5OGM0LjEzOS0xLjcsOS40OS0wLjAwNCwxMy42MzMsNC4zMjMgIGMwLjY5MSwwLjcyMywxLjMwMywxLjQ1MywxLjg3NSwyLjE4NGMtMS42NzQtMy42OTktNC41MS03Ljk1OC0xMS4xMjEtMTQuMjY5Yy02LjM3MS02LjA4MS0xNS44NzktOC45MTItMjEuNjQyLTYuNDUgIGMtMy44MTIsMS42MjktNS44MjksNS40NTQtNS44MzQsMTEuMDYxYy0wLjAxLDExLjgxNSwxNi4zMTIsMjEuNjQ2LDI1LjA3MiwyNi4wNzJDNjMuNzc1LDczLjc0Niw2MC4xMTUsNjkuMTY4LDYwLjAyNyw2My43NjF6Ij48L3BhdGg+PHBhdGggZD0iTTI3LjU5MSwzOC4xM2MyLjU1Ni03LjU0NSw5LjMzMS0xMS41NjgsMTguMTExLTEwLjc1OGMxMS41MjksMS4wNjEsMjAuMDE1LDcuMTQ4LDI2LjAxMywxMy45MiAgQzYxLjUsMjYuMDU0LDQ4Ljk2MywyMC4zMzksNDguODE3LDIwLjI3NGMtMy4yOTYtMS42ODgtNi43OTctMi41MzEtMTAuNDU3LTIuNTMxYy0xMi43NzQsMC0yMy4xNjcsMTAuNTgtMjMuMTY3LDIzLjU4MyAgYzAsNy45NjEsNC4yMDEsMTUuNTIxLDExLjIzOCwyMC4yMjJjMy43ODksMi41MywxMS40ODgsNS44MjQsMjAuMDQ2LDkuMDM4Yy0yLjI1NC0xLjIxNS00LjU2NC0yLjU0Ny02Ljg3NS00ICBDMjcuODg1LDU5LjIxOSwyNC42OSw0Ni42OTQsMjcuNTkxLDM4LjEzeiI+PC9wYXRoPjxwYXRoIGQ9Ik03Ny42MzcsNTkuNzY5Yy0zLjU2OC0zLjcyOS04LjA1Ny01LjI0Mi0xMS40MjgtMy44NTVjLTIuNzIxLDEuMTE4LTQuMjQ2LDMuOTY3LTQuMTgyLDcuODE0ICBjMC4xNDgsOS4wMzUsMTEuMzEzLDE1LjMxOCwxMy41ODgsMTYuNTkyYzMuNDg5LDEuOTU0LDcuNjI1LDIuMDg3LDcuOTA0LDEuOTM4czAuMjc5LTAuMTQ5LDAuNTMxLTAuNjUxICBjMC42Ni0xLjMwOSwxLjA1My00LjI3NSwwLjM2MS04Ljk2NkM4My43NzcsNjkuNDg5LDgyLjA5Niw2NC40MjcsNzcuNjM3LDU5Ljc2OXoiPjwvcGF0aD48L3N2Zz4="); + height: 32px; + pointer-events: none; + background-repeat: no-repeat; + background-size: 32px; + width: 32px; +} + +.app-title { + font-family: Inter; + font-style: normal; + font-weight: 600; + letter-spacing: 0px; + + h1 { + font-size: 36px; + margin: 0px; + } +} + +.ant-card-cover { + position: relative; +} + +.card-close-button { + position: absolute; + top: 5px; + left: 5px; + z-index: 1; + width: 30px; + height: 30px; + border-radius: 30px; + background-color: #434343 !important; + + :hover { + background-color: #434343; + } +} + +.text-center { + align-self: center; + margin-left: auto; + margin-right: auto; +} + +.ant-tabs-tab-active { + +} + +.ant-upload.ant-upload-drag { + border-radius: 8px; + border-color: transparent; +} + +.tab-title { + font-family: Inter; + font-style: normal; + font-weight: 600; + font-size: 24px; + line-height: 26px; + display: flex; + align-items: center; + letter-spacing: 0.02em; + + color: @text-color-secondary; +} + +.ant-tabs { + width: 100%; +} + +.ant-tabs-tab-active { + .tab-title { + color: @text-color; + } +} diff --git a/packages/metavinci/src/App.tsx b/packages/metavinci/src/App.tsx new file mode 100644 index 0000000..d2220c7 --- /dev/null +++ b/packages/metavinci/src/App.tsx @@ -0,0 +1,9 @@ +import React from 'react'; +import './App.less'; +import { Routes } from './routes'; + +function App() { + return ; +} + +export default App; diff --git a/packages/metavinci/src/actions/addTokensToVault.ts b/packages/metavinci/src/actions/addTokensToVault.ts new file mode 100644 index 0000000..d6af722 --- /dev/null +++ b/packages/metavinci/src/actions/addTokensToVault.ts @@ -0,0 +1,95 @@ +import { + Account, + Connection, + PublicKey, + TransactionInstruction, +} from '@solana/web3.js'; +import { utils, actions, models } from '@oyster/common'; + +import { AccountLayout } from '@solana/spl-token'; +import BN from 'bn.js'; +const { createTokenAccount, addTokenToInactiveVault, VAULT_PREFIX } = actions; +const { approve } = models; + +const BATCH_SIZE = 4; +// This command batches out adding tokens to a vault using a prefilled payer account, and then activates and combines +// the vault for use. It issues a series of transaction instructions and signers for the sendTransactions batch. +export async function addTokensToVault( + connection: Connection, + wallet: any, + vault: PublicKey, + nfts: { tokenAccount: PublicKey; tokenMint: PublicKey; amount: BN }[], +): Promise<{ + instructions: Array; + signers: Array; + stores: PublicKey[]; +}> { + const PROGRAM_IDS = utils.programIds(); + + const accountRentExempt = await connection.getMinimumBalanceForRentExemption( + AccountLayout.span, + ); + + const vaultAuthority = ( + await PublicKey.findProgramAddress( + [Buffer.from(VAULT_PREFIX), PROGRAM_IDS.vault.toBuffer()], + PROGRAM_IDS.vault, + ) + )[0]; + + let batchCounter = 0; + + let signers: Array = []; + let instructions: Array = []; + let newStores: PublicKey[] = []; + + let currSigners: Account[] = []; + let currInstructions: TransactionInstruction[] = []; + for (let i = 0; i < nfts.length; i++) { + let nft = nfts[i]; + const newStoreAccount = createTokenAccount( + currInstructions, + wallet.publicKey, + accountRentExempt, + nft.tokenMint, + vaultAuthority, + currSigners, + ); + newStores.push(newStoreAccount); + + const transferAuthority = approve( + currInstructions, + [], + nft.tokenAccount, + wallet.publicKey, + nft.amount.toNumber(), + ); + + currSigners.push(transferAuthority); + + await addTokenToInactiveVault( + nft.amount, + nft.tokenMint, + nft.tokenAccount, + newStoreAccount, + vault, + wallet.publicKey, + wallet.publicKey, + transferAuthority.publicKey, + currInstructions, + ); + + if (batchCounter == BATCH_SIZE) { + signers.push(currSigners); + instructions.push(currInstructions); + batchCounter = 0; + currSigners = []; + currInstructions = []; + } + } + + signers.push(currSigners); + instructions.push(currInstructions); + + return { signers, instructions, stores: newStores }; +} diff --git a/packages/metavinci/src/actions/closeVault.ts b/packages/metavinci/src/actions/closeVault.ts new file mode 100644 index 0000000..20d78da --- /dev/null +++ b/packages/metavinci/src/actions/closeVault.ts @@ -0,0 +1,132 @@ +import { + Account, + Connection, + PublicKey, + TransactionInstruction, +} from '@solana/web3.js'; +import { utils, actions, models } from '@oyster/common'; + +import { AccountLayout } from '@solana/spl-token'; +import BN from 'bn.js'; +import { METAPLEX_PREFIX } from '../models/metaplex'; +const { + createTokenAccount, + activateVault, + combineVault, + VAULT_PREFIX, + AUCTION_PREFIX, +} = actions; +const { approve } = models; + +// This command "closes" the vault, by activating & combining it in one go, handing it over to the auction manager +// authority (that may or may not exist yet.) +export async function closeVault( + connection: Connection, + wallet: any, + vault: PublicKey, + fractionMint: PublicKey, + fractionTreasury: PublicKey, + redeemTreasury: PublicKey, + priceMint: PublicKey, + externalPriceAccount: PublicKey, +): Promise<{ + instructions: TransactionInstruction[]; + signers: Account[]; +}> { + const PROGRAM_IDS = utils.programIds(); + + const accountRentExempt = await connection.getMinimumBalanceForRentExemption( + AccountLayout.span, + ); + let signers: Account[] = []; + let instructions: TransactionInstruction[] = []; + + const auctionKey: PublicKey = ( + await PublicKey.findProgramAddress( + [ + Buffer.from(AUCTION_PREFIX), + PROGRAM_IDS.auction.toBuffer(), + vault.toBuffer(), + ], + PROGRAM_IDS.auction, + ) + )[0]; + + const auctionManagerKey: PublicKey = ( + await PublicKey.findProgramAddress( + [Buffer.from(METAPLEX_PREFIX), auctionKey.toBuffer()], + PROGRAM_IDS.metaplex, + ) + )[0]; + + await activateVault( + new BN(0), + vault, + fractionMint, + fractionTreasury, + wallet.publicKey, + instructions, + ); + + const outstandingShareAccount = createTokenAccount( + instructions, + wallet.publicKey, + accountRentExempt, + fractionMint, + wallet.publicKey, + signers, + ); + + const payingTokenAccount = createTokenAccount( + instructions, + wallet.publicKey, + accountRentExempt, + priceMint, + wallet.publicKey, + signers, + ); + + let transferAuthority = new Account(); + + // Shouldn't need to pay anything since we activated vault with 0 shares, but we still + // need this setup anyway. + approve( + instructions, + [], + payingTokenAccount, + wallet.publicKey, + 0, + false, + undefined, + transferAuthority, + ); + + approve( + instructions, + [], + outstandingShareAccount, + wallet.publicKey, + 0, + false, + undefined, + transferAuthority, + ); + + signers.push(transferAuthority); + + await combineVault( + vault, + outstandingShareAccount, + payingTokenAccount, + fractionMint, + fractionTreasury, + redeemTreasury, + auctionManagerKey, + wallet.publicKey, + transferAuthority.publicKey, + externalPriceAccount, + instructions, + ); + + return { instructions, signers }; +} diff --git a/packages/metavinci/src/actions/createAuctionManager.ts b/packages/metavinci/src/actions/createAuctionManager.ts new file mode 100644 index 0000000..edc77a5 --- /dev/null +++ b/packages/metavinci/src/actions/createAuctionManager.ts @@ -0,0 +1,324 @@ +import { + Account, + Connection, + PublicKey, + TransactionInstruction, +} from '@solana/web3.js'; +import { + actions, + Metadata, + ParsedAccount, + WinnerLimit, + MasterEdition, + NameSymbolTuple, + getMetadata, + SequenceType, + sendTransactions, + getSafetyDepositBox, + Edition, +} from '@oyster/common'; + +import { AccountLayout } from '@solana/spl-token'; +import BN from 'bn.js'; +import { + AuctionManagerSettings, + getAuctionKeys, + initAuctionManager, + startAuction, + validateSafetyDepositBox, +} from '../models/metaplex'; +import { createVault } from './createVault'; +import { closeVault } from './closeVault'; +import { addTokensToVault } from './addTokensToVault'; +import { makeAuction } from './makeAuction'; +import { createExternalPriceAccount } from './createExternalPriceAccount'; +const { createTokenAccount } = actions; + +interface normalPattern { + instructions: TransactionInstruction[]; + signers: Account[]; +} +interface byType { + addTokens: { + instructions: Array; + signers: Array; + }; + validateBoxes: { + instructions: Array; + signers: Array; + }; + createVault: normalPattern; + closeVault: normalPattern; + makeAuction: normalPattern; + initAuctionManager: normalPattern; + startAuction: normalPattern; + externalPriceAccount: normalPattern; +} + +export interface SafetyDepositDraft { + metadata: ParsedAccount; + nameSymbol?: ParsedAccount; + masterEdition?: ParsedAccount; + edition?: ParsedAccount; + holding: PublicKey; +} + +// This is a super command that executes many transactions to create a Vault, Auction, and AuctionManager starting +// from some AuctionManagerSettings. +export async function createAuctionManager( + connection: Connection, + wallet: any, + settings: AuctionManagerSettings, + winnerLimit: WinnerLimit, + endAuctionAt: BN, + auctionGap: BN, + safetyDeposits: SafetyDepositDraft[], + paymentMint: PublicKey, +): Promise<{ + vault: PublicKey; + auction: PublicKey; + auctionManager: PublicKey; +}> { + const { + externalPriceAccount, + priceMint, + instructions: epaInstructions, + signers: epaSigners, + } = await createExternalPriceAccount(connection, wallet); + + const { + instructions: createVaultInstructions, + signers: createVaultSigners, + vault, + fractionalMint, + redeemTreasury, + fractionTreasury, + } = await createVault(connection, wallet, priceMint, externalPriceAccount); + + const { + instructions: makeAuctionInstructions, + signers: makeAuctionSigners, + auction, + } = await makeAuction( + wallet, + winnerLimit, + vault, + endAuctionAt, + auctionGap, + paymentMint, + ); + + let nftConfigs = safetyDeposits.map((w, i) => ({ + tokenAccount: w.holding, + tokenMint: w.metadata.info.mint, + amount: new BN( + settings.winningConfigs.find(w => w.safetyDepositBoxIndex == i)?.amount || + 1, + ), + })); + + let openEditionSafetyDeposit = undefined; + if ( + settings.openEditionConfig != null && + settings.openEditionConfig != undefined + ) { + openEditionSafetyDeposit = safetyDeposits[settings.openEditionConfig]; + } + + const { + instructions: auctionManagerInstructions, + signers: auctionManagerSigners, + auctionManager, + } = await setupAuctionManagerInstructions( + connection, + wallet, + vault, + paymentMint, + settings, + openEditionSafetyDeposit, + ); + + const { + instructions: addTokenInstructions, + signers: addTokenSigners, + stores, + } = await addTokensToVault(connection, wallet, vault, nftConfigs); + + let lookup: byType = { + externalPriceAccount: { + instructions: epaInstructions, + signers: epaSigners, + }, + createVault: { + instructions: createVaultInstructions, + signers: createVaultSigners, + }, + closeVault: await closeVault( + connection, + wallet, + vault, + fractionalMint, + fractionTreasury, + redeemTreasury, + priceMint, + externalPriceAccount, + ), + addTokens: { instructions: addTokenInstructions, signers: addTokenSigners }, + makeAuction: { + instructions: makeAuctionInstructions, + signers: makeAuctionSigners, + }, + initAuctionManager: { + instructions: auctionManagerInstructions, + signers: auctionManagerSigners, + }, + startAuction: await setupStartAuction(wallet, vault), + validateBoxes: await validateBoxes( + wallet, + vault, + // No need to validate open edition, it's already been during init + safetyDeposits.filter((_, i) => i != settings.openEditionConfig), + stores, + ), + }; + + console.log('Lookup', lookup.validateBoxes); + let signers: Account[][] = [ + lookup.externalPriceAccount.signers, + lookup.createVault.signers, + ...lookup.addTokens.signers, + lookup.closeVault.signers, + lookup.makeAuction.signers, + lookup.initAuctionManager.signers, + ...lookup.validateBoxes.signers, + lookup.startAuction.signers, + ]; + let instructions: TransactionInstruction[][] = [ + lookup.externalPriceAccount.instructions, + lookup.createVault.instructions, + ...lookup.addTokens.instructions, + lookup.closeVault.instructions, + lookup.makeAuction.instructions, + lookup.initAuctionManager.instructions, + ...lookup.validateBoxes.instructions, + lookup.startAuction.instructions, + ]; + + let stopPoint = 0; + while (stopPoint < instructions.length) { + stopPoint = await sendTransactions( + connection, + wallet, + instructions, + signers, + SequenceType.StopOnFailure, + 'max', + ); + } + + return { vault, auction, auctionManager }; +} + +async function setupAuctionManagerInstructions( + connection: Connection, + wallet: any, + vault: PublicKey, + paymentMint: PublicKey, + settings: AuctionManagerSettings, + openEditionSafetyDeposit?: SafetyDepositDraft, +): Promise<{ + instructions: TransactionInstruction[]; + signers: Account[]; + auctionManager: PublicKey; +}> { + let signers: Account[] = []; + let instructions: TransactionInstruction[] = []; + const accountRentExempt = await connection.getMinimumBalanceForRentExemption( + AccountLayout.span, + ); + + const { auctionManagerKey } = await getAuctionKeys(vault); + + const acceptPayment = createTokenAccount( + instructions, + wallet.publicKey, + accountRentExempt, + paymentMint, + auctionManagerKey, + signers, + ); + + await initAuctionManager( + vault, + openEditionSafetyDeposit?.metadata.pubkey, + openEditionSafetyDeposit?.nameSymbol?.pubkey, + wallet.publicKey, + openEditionSafetyDeposit?.masterEdition?.pubkey, + openEditionSafetyDeposit?.metadata.info.mint, + openEditionSafetyDeposit?.masterEdition?.info.masterMint, + wallet.publicKey, + wallet.publicKey, + wallet.publicKey, + acceptPayment, + settings, + instructions, + ); + + return { instructions, signers, auctionManager: auctionManagerKey }; +} + +async function setupStartAuction( + wallet: any, + vault: PublicKey, +): Promise<{ + instructions: TransactionInstruction[]; + signers: Account[]; +}> { + let signers: Account[] = []; + let instructions: TransactionInstruction[] = []; + + await startAuction(vault, wallet.publicKey, instructions); + + return { instructions, signers }; +} + +async function validateBoxes( + wallet: any, + vault: PublicKey, + safetyDeposits: SafetyDepositDraft[], + stores: PublicKey[], +): Promise<{ + instructions: TransactionInstruction[][]; + signers: Account[][]; +}> { + let signers: Account[][] = []; + let instructions: TransactionInstruction[][] = []; + + for (let i = 0; i < safetyDeposits.length; i++) { + let tokenSigners: Account[] = []; + let tokenInstructions: TransactionInstruction[] = []; + const safetyDepositBox: PublicKey = await getSafetyDepositBox( + vault, + safetyDeposits[i].metadata.info.mint, + ); + + await validateSafetyDepositBox( + vault, + safetyDeposits[i].metadata.pubkey, + safetyDeposits[i].nameSymbol?.pubkey, + safetyDepositBox, + stores[i], + safetyDeposits[i].metadata.info.mint, + wallet.publicKey, + wallet.publicKey, + wallet.publicKey, + tokenInstructions, + safetyDeposits[i].masterEdition?.info.masterMint, + safetyDeposits[i].masterEdition ? wallet.publicKey : undefined, + ); + + signers.push(tokenSigners); + instructions.push(tokenInstructions); + } + return { instructions, signers }; +} diff --git a/packages/metavinci/src/actions/createExternalPriceAccount.ts b/packages/metavinci/src/actions/createExternalPriceAccount.ts new file mode 100644 index 0000000..430cf90 --- /dev/null +++ b/packages/metavinci/src/actions/createExternalPriceAccount.ts @@ -0,0 +1,81 @@ +import { + Account, + Connection, + PublicKey, + SystemProgram, + TransactionInstruction, +} from '@solana/web3.js'; +import { utils, actions, createMint, VAULT_SCHEMA } from '@oyster/common'; + +import { MintLayout } from '@solana/spl-token'; +import BN from 'bn.js'; +const { + updateExternalPriceAccount, + ExternalPriceAccount, + MAX_EXTERNAL_ACCOUNT_SIZE, +} = actions; + +// This command creates the external pricing oracle +export async function createExternalPriceAccount( + connection: Connection, + wallet: any, +): Promise<{ + priceMint: PublicKey; + externalPriceAccount: PublicKey; + instructions: TransactionInstruction[]; + signers: Account[]; +}> { + const PROGRAM_IDS = utils.programIds(); + + let signers: Account[] = []; + let instructions: TransactionInstruction[] = []; + + const mintRentExempt = await connection.getMinimumBalanceForRentExemption( + MintLayout.span, + ); + + const epaRentExempt = await connection.getMinimumBalanceForRentExemption( + MAX_EXTERNAL_ACCOUNT_SIZE, + ); + + let externalPriceAccount = new Account(); + + const priceMint = createMint( + instructions, + wallet.publicKey, + mintRentExempt, + 0, + wallet.publicKey, + wallet.publicKey, + signers, + ); + + let epaStruct = new ExternalPriceAccount({ + pricePerShare: new BN(0), + priceMint: priceMint, + allowedToCombine: true, + }); + + const uninitializedEPA = SystemProgram.createAccount({ + fromPubkey: wallet.publicKey, + newAccountPubkey: externalPriceAccount.publicKey, + lamports: epaRentExempt, + space: MAX_EXTERNAL_ACCOUNT_SIZE, + programId: PROGRAM_IDS.vault, + }); + instructions.push(uninitializedEPA); + signers.push(externalPriceAccount); + + await updateExternalPriceAccount( + externalPriceAccount.publicKey, + epaStruct, + instructions, + ); + + return { + externalPriceAccount: externalPriceAccount.publicKey, + priceMint, + instructions, + signers, + }; +} diff --git a/packages/metavinci/src/actions/createVault.ts b/packages/metavinci/src/actions/createVault.ts new file mode 100644 index 0000000..8a28bfb --- /dev/null +++ b/packages/metavinci/src/actions/createVault.ts @@ -0,0 +1,111 @@ +import { + Account, + Connection, + PublicKey, + SystemProgram, + TransactionInstruction, +} from '@solana/web3.js'; +import { utils, actions, createMint } from '@oyster/common'; + +import { AccountLayout, MintLayout } from '@solana/spl-token'; +const { createTokenAccount, initVault, MAX_VAULT_SIZE, VAULT_PREFIX } = actions; + +// This command creates the external pricing oracle a vault +// This gets the vault ready for adding the tokens. +export async function createVault( + connection: Connection, + wallet: any, + priceMint: PublicKey, + externalPriceAccount: PublicKey, +): Promise<{ + vault: PublicKey; + fractionalMint: PublicKey; + redeemTreasury: PublicKey; + fractionTreasury: PublicKey; + instructions: TransactionInstruction[]; + signers: Account[]; +}> { + const PROGRAM_IDS = utils.programIds(); + + let signers: Account[] = []; + let instructions: TransactionInstruction[] = []; + + const accountRentExempt = await connection.getMinimumBalanceForRentExemption( + AccountLayout.span, + ); + + const mintRentExempt = await connection.getMinimumBalanceForRentExemption( + MintLayout.span, + ); + + const vaultRentExempt = await connection.getMinimumBalanceForRentExemption( + MAX_VAULT_SIZE, + ); + + let vault = new Account(); + + const vaultAuthority = ( + await PublicKey.findProgramAddress( + [Buffer.from(VAULT_PREFIX), PROGRAM_IDS.vault.toBuffer()], + PROGRAM_IDS.vault, + ) + )[0]; + + const fractionalMint = createMint( + instructions, + wallet.publicKey, + mintRentExempt, + 0, + vaultAuthority, + vaultAuthority, + signers, + ); + + const redeemTreasury = createTokenAccount( + instructions, + wallet.publicKey, + accountRentExempt, + priceMint, + vaultAuthority, + signers, + ); + + const fractionTreasury = createTokenAccount( + instructions, + wallet.publicKey, + accountRentExempt, + fractionalMint, + vaultAuthority, + signers, + ); + + const uninitializedVault = SystemProgram.createAccount({ + fromPubkey: wallet.publicKey, + newAccountPubkey: vault.publicKey, + lamports: vaultRentExempt, + space: MAX_VAULT_SIZE, + programId: PROGRAM_IDS.vault, + }); + instructions.push(uninitializedVault); + signers.push(vault); + + await initVault( + true, + fractionalMint, + redeemTreasury, + fractionTreasury, + vault.publicKey, + wallet.publicKey, + externalPriceAccount, + instructions, + ); + + return { + vault: vault.publicKey, + fractionalMint, + redeemTreasury, + fractionTreasury, + signers, + instructions, + }; +} diff --git a/packages/metavinci/src/actions/index.ts b/packages/metavinci/src/actions/index.ts new file mode 100644 index 0000000..f6b5030 --- /dev/null +++ b/packages/metavinci/src/actions/index.ts @@ -0,0 +1,3 @@ +export * from './nft'; +export * from './createVault'; +export * from './makeAuction'; diff --git a/packages/metavinci/src/actions/makeAuction.ts b/packages/metavinci/src/actions/makeAuction.ts new file mode 100644 index 0000000..22aa0e1 --- /dev/null +++ b/packages/metavinci/src/actions/makeAuction.ts @@ -0,0 +1,55 @@ +import { Account, PublicKey, TransactionInstruction } from '@solana/web3.js'; +import { utils, actions, WinnerLimit } from '@oyster/common'; + +import BN from 'bn.js'; +import { METAPLEX_PREFIX } from '../models/metaplex'; +const { AUCTION_PREFIX, createAuction } = actions; + +// This command makes an auction +export async function makeAuction( + wallet: any, + winnerLimit: WinnerLimit, + vault: PublicKey, + endAuctionAt: BN, + auctionGap: BN, + paymentMint: PublicKey, +): Promise<{ + auction: PublicKey; + instructions: TransactionInstruction[]; + signers: Account[]; +}> { + const PROGRAM_IDS = utils.programIds(); + + let signers: Account[] = []; + let instructions: TransactionInstruction[] = []; + const auctionKey: PublicKey = ( + await PublicKey.findProgramAddress( + [ + Buffer.from(AUCTION_PREFIX), + PROGRAM_IDS.auction.toBuffer(), + vault.toBuffer(), + ], + PROGRAM_IDS.auction, + ) + )[0]; + + const auctionManagerKey: PublicKey = ( + await PublicKey.findProgramAddress( + [Buffer.from(METAPLEX_PREFIX), auctionKey.toBuffer()], + PROGRAM_IDS.metaplex, + ) + )[0]; + + createAuction( + winnerLimit, + vault, + endAuctionAt, + auctionGap, + paymentMint, + auctionManagerKey, + wallet.publicKey, + instructions, + ); + + return { instructions, signers, auction: auctionKey }; +} diff --git a/packages/metavinci/src/actions/nft.tsx b/packages/metavinci/src/actions/nft.tsx new file mode 100644 index 0000000..6586ec3 --- /dev/null +++ b/packages/metavinci/src/actions/nft.tsx @@ -0,0 +1,306 @@ +import { + createAssociatedTokenAccountInstruction, + createMint, + createMetadata, + transferUpdateAuthority, + programIds, + sendTransaction, + sendTransactions, + notify, + ENV, + updateMetadata, + createMasterEdition, + sendTransactionWithRetry, +} from '@oyster/common'; +import React from 'react'; +import { MintLayout, Token } from '@solana/spl-token'; +import { WalletAdapter } from '@solana/wallet-base'; +import { + Account, + Connection, + PublicKey, + SystemProgram, + TransactionInstruction, +} from '@solana/web3.js'; +import crypto from 'crypto'; +import { getAssetCostToStore } from '../utils/assets'; +import { AR_SOL_HOLDER_ID } from '../utils/ids'; +const RESERVED_TXN_MANIFEST = 'manifest.json'; + +interface IArweaveResult { + error?: string; + messages?: Array<{ + filename: string; + status: 'success' | 'fail'; + transactionId?: string; + error?: string; + }>; +} + +export const mintNFT = async ( + connection: Connection, + wallet: WalletAdapter | undefined, + env: ENV, + files: File[], + metadata: { name: string; symbol: string }, +): Promise<{ + metadataAccount: PublicKey, +} | void> => { + if (!wallet?.publicKey) { + return; + } + const realFiles: File[] = [ + ...files, + new File([JSON.stringify(metadata)], 'metadata.json'), + ]; + + const { + instructions: pushInstructions, + signers: pushSigners, + } = await prepPayForFilesTxn(wallet, realFiles, metadata); + + const TOKEN_PROGRAM_ID = programIds().token; + + // Allocate memory for the account + const mintRent = await connection.getMinimumBalanceForRentExemption( + MintLayout.span, + ); + + // This owner is a temporary signer and owner of metadata we use to circumvent requesting signing + // twice post Arweave. We store in an account (payer) and use it post-Arweave to update MD with new link + // then give control back to the user. + // const payer = new Account(); + const payerPublicKey = wallet.publicKey; + const instructions: TransactionInstruction[] = [...pushInstructions]; + const signers: Account[] = [...pushSigners]; + + // This is only temporarily owned by wallet...transferred to program by createMasterEdition below + const mintKey = createMint( + instructions, + wallet.publicKey, + mintRent, + 0, + // Some weird bug with phantom where it's public key doesnt mesh with data encode well + payerPublicKey, + payerPublicKey, + signers, + ); + + const recipientKey: PublicKey = ( + await PublicKey.findProgramAddress( + [ + wallet.publicKey.toBuffer(), + programIds().token.toBuffer(), + mintKey.toBuffer(), + ], + programIds().associatedToken, + ) + )[0]; + + createAssociatedTokenAccountInstruction( + instructions, + recipientKey, + wallet.publicKey, + wallet.publicKey, + mintKey, + ); + + instructions.push( + Token.createMintToInstruction( + TOKEN_PROGRAM_ID, + mintKey, + recipientKey, + payerPublicKey, + [], + 1, + ), + ); + + const [metadataAccount, nameSymbolAccount] = await createMetadata( + metadata.symbol, + metadata.name, + `https://-------.---/rfX69WKd7Bin_RTbcnH4wM3BuWWsR_ZhWSSqZBLYdMY`, + true, + payerPublicKey, + mintKey, + payerPublicKey, + instructions, + wallet.publicKey, + ); + + // TODO: enable when using payer account to avoid 2nd popup + // const block = await connection.getRecentBlockhash('singleGossip'); + // instructions.push( + // SystemProgram.transfer({ + // fromPubkey: wallet.publicKey, + // toPubkey: payerPublicKey, + // lamports: 0.5 * LAMPORTS_PER_SOL // block.feeCalculator.lamportsPerSignature * 3 + mintRent, // TODO + // }), + // ); + + const { txid } = await sendTransactionWithRetry( + connection, + wallet, + instructions, + signers, + ); + + try { + await connection.confirmTransaction(txid, 'max'); + } catch { + // ignore + } + + // Force wait for max confirmations + // await connection.confirmTransaction(txid, 'max'); + await connection.getParsedConfirmedTransaction(txid, 'confirmed'); + + // this means we're done getting AR txn setup. Ship it off to ARWeave! + const data = new FormData(); + + const tags = realFiles.reduce( + (acc: Record>, f) => { + acc[f.name] = [{ name: 'mint', value: mintKey.toBase58() }]; + return acc; + }, + {}, + ); + data.append('tags', JSON.stringify(tags)); + data.append('transaction', txid); + realFiles.map(f => data.append('file[]', f)); + + const result: IArweaveResult = await ( + await fetch( + // TODO: add CNAME + env === 'mainnet-beta' + ? 'https://us-central1-principal-lane-200702.cloudfunctions.net/uploadFileProd' + : 'https://us-central1-principal-lane-200702.cloudfunctions.net/uploadFile', + { + method: 'POST', + body: data, + }, + ) + ).json(); + + const metadataFile = result.messages?.find( + m => m.filename == RESERVED_TXN_MANIFEST, + ); + if (metadataFile?.transactionId && wallet.publicKey) { + const updateInstructions: TransactionInstruction[] = []; + const updateSigners: Account[] = []; + + // TODO: connect to testnet arweave + const arweaveLink = `https://arweave.net/${metadataFile.transactionId}`; + await updateMetadata( + metadata.symbol, + metadata.name, + arweaveLink, + undefined, + mintKey, + payerPublicKey, + updateInstructions, + metadataAccount, + nameSymbolAccount, + ); + + // // This mint, which allows limited editions to be made, stays with user's wallet. + const masterMint = createMint( + updateInstructions, + payerPublicKey, + mintRent, + 0, + payerPublicKey, + payerPublicKey, + updateSigners, + ); + + // // In this instruction, mint authority will be removed from the main mint, while + // // minting authority will be maintained for the master mint (which we want.) + await createMasterEdition( + metadata.symbol, + metadata.name, + undefined, + mintKey, + masterMint, + payerPublicKey, + payerPublicKey, + updateInstructions, + payerPublicKey, + ); + + // TODO: enable when using payer account to avoid 2nd popup + // await transferUpdateAuthority( + // metadataAccount, + // payerPublicKey, + // wallet.publicKey, + // updateInstructions, + // ); + + const txid = await sendTransactionWithRetry( + connection, + wallet, + updateInstructions, + updateSigners, + ); + + notify({ + message: 'Art created on Solana', + description: ( + + Arweave Link + + ), + type: 'success', + }); + + // TODO: refund funds + + // send transfer back to user + } + // TODO: + // 1. Jordan: --- upload file and metadata to storage API + // 2. pay for storage by hashing files and attaching memo for each file + + return { metadataAccount } +}; + +export const prepPayForFilesTxn = async ( + wallet: WalletAdapter, + files: File[], + metadata: any, +): Promise<{ + instructions: TransactionInstruction[]; + signers: Account[]; +}> => { + const memo = programIds().memo; + + const instructions: TransactionInstruction[] = []; + const signers: Account[] = []; + + if (wallet.publicKey) + instructions.push( + SystemProgram.transfer({ + fromPubkey: wallet.publicKey, + toPubkey: AR_SOL_HOLDER_ID, + lamports: await getAssetCostToStore(files), + }), + ); + + for (let i = 0; i < files.length; i++) { + const hashSum = crypto.createHash('sha256'); + hashSum.update(await files[i].text()); + const hex = hashSum.digest('hex'); + instructions.push( + new TransactionInstruction({ + keys: [], + programId: memo, + data: Buffer.from(hex), + }), + ); + } + + return { + instructions, + signers, + }; +}; diff --git a/packages/metavinci/src/actions/sendPlaceBid.ts b/packages/metavinci/src/actions/sendPlaceBid.ts new file mode 100644 index 0000000..af157c8 --- /dev/null +++ b/packages/metavinci/src/actions/sendPlaceBid.ts @@ -0,0 +1,78 @@ +import { + Account, + Connection, + PublicKey, + TransactionInstruction, +} from '@solana/web3.js'; +import { + actions, + ParsedAccount, + SequenceType, + sendTransactionWithRetry, + placeBid, + programIds, + BidderPot, + models, +} from '@oyster/common'; + +import { AccountLayout } from '@solana/spl-token'; +import { AuctionView } from '../hooks'; +import BN from 'bn.js'; +const { createTokenAccount } = actions; +const { approve } = models; + +export async function sendPlaceBid( + connection: Connection, + wallet: any, + bidderAccount: PublicKey, + auctionView: AuctionView, + amount: number, +) { + let signers: Account[] = []; + let instructions: TransactionInstruction[] = []; + + const accountRentExempt = await connection.getMinimumBalanceForRentExemption( + AccountLayout.span, + ); + + let bidderPotTokenAccount: PublicKey; + if (!auctionView.myBidderPot) { + bidderPotTokenAccount = createTokenAccount( + instructions, + wallet.publicKey, + accountRentExempt, + auctionView.auction.info.tokenMint, + programIds().auction, + signers, + ); + } else bidderPotTokenAccount = auctionView.myBidderPot?.info.bidderPot; + + const transferAuthority = approve( + instructions, + [], + bidderAccount, + wallet.publicKey, + amount, + ); + + signers.push(transferAuthority); + + await placeBid( + bidderAccount, + bidderPotTokenAccount, + auctionView.auction.info.tokenMint, + transferAuthority.publicKey, + wallet.publicKey, + auctionView.auctionManager.info.vault, + new BN(amount), + instructions, + ); + + await sendTransactionWithRetry( + connection, + wallet, + instructions, + signers, + 'single', + ); +} diff --git a/packages/metavinci/src/actions/sendRedeemBid.ts b/packages/metavinci/src/actions/sendRedeemBid.ts new file mode 100644 index 0000000..aa505ad --- /dev/null +++ b/packages/metavinci/src/actions/sendRedeemBid.ts @@ -0,0 +1,493 @@ +import { + Account, + Connection, + PublicKey, + TransactionInstruction, +} from '@solana/web3.js'; +import { + actions, + ParsedAccount, + programIds, + models, + TokenAccount, + getNameSymbol, + createMint, + mintNewEditionFromMasterEditionViaToken, + SafetyDepositBox, + SequenceType, + sendTransactions, + sendSignedTransaction, + sendTransactionWithRetry, +} from '@oyster/common'; + +import { AccountLayout, MintLayout, Token } from '@solana/spl-token'; +import { AuctionView, AuctionViewItem } from '../hooks'; +import { + EditionType, + getOriginalAuthority, + NonWinningConstraint, + redeemBid, + redeemLimitedEditionBid, + redeemMasterEditionBid, + redeemOpenEditionBid, + WinningConfig, + WinningConstraint, +} from '../models/metaplex'; +const { createTokenAccount } = actions; +const { approve } = models; + +export async function sendRedeemBid( + connection: Connection, + wallet: any, + auctionView: AuctionView, + accountsByMint: Map, +) { + let signers: Array = []; + let instructions: Array = []; + + const accountRentExempt = await connection.getMinimumBalanceForRentExemption( + AccountLayout.span, + ); + + const mintRentExempt = await connection.getMinimumBalanceForRentExemption( + MintLayout.span, + ); + + let winnerIndex = null; + if (auctionView.myBidderPot?.pubkey) + winnerIndex = auctionView.auction.info.bidState.getWinnerIndex( + auctionView.myBidderPot?.pubkey, + ); + console.log('Winner index', winnerIndex); + + if (winnerIndex != null) { + const winningConfig = + auctionView.auctionManager.info.settings.winningConfigs[winnerIndex]; + const item = auctionView.items[winnerIndex]; + const safetyDeposit = item.safetyDeposit; + switch (winningConfig.editionType) { + case EditionType.LimitedEdition: + console.log('Redeeming limited'); + await setupRedeemLimitedInstructions( + connection, + auctionView, + accountsByMint, + accountRentExempt, + mintRentExempt, + wallet, + safetyDeposit, + item, + signers, + instructions, + winningConfig, + ); + break; + case EditionType.MasterEdition: + console.log('Redeeming master'); + await setupRedeemMasterInstructions( + auctionView, + accountsByMint, + accountRentExempt, + wallet, + safetyDeposit, + item, + signers, + instructions, + ); + break; + case EditionType.NA: + console.log('Redeeming normal'); + await setupRedeemInstructions( + auctionView, + accountsByMint, + accountRentExempt, + wallet, + safetyDeposit, + signers, + instructions, + ); + break; + } + } + + const eligibleForOpenEdition = + (winnerIndex == null && + auctionView.auctionManager.info.settings + .openEditionNonWinningConstraint != + NonWinningConstraint.NoOpenEdition) || + (winnerIndex != null && + auctionView.auctionManager.info.settings.openEditionWinnerConstraint != + WinningConstraint.NoOpenEdition); + + if (auctionView.openEditionItem && eligibleForOpenEdition) { + const item = auctionView.openEditionItem; + const safetyDeposit = item.safetyDeposit; + await setupRedeemOpenInstructions( + auctionView, + accountsByMint, + accountRentExempt, + mintRentExempt, + wallet, + safetyDeposit, + item, + signers, + instructions, + ); + } + + if (signers.length == 1) + await sendTransactionWithRetry( + connection, + wallet, + instructions[0], + signers[0], + 'single', + ); + else + await sendTransactions( + connection, + wallet, + instructions, + signers, + SequenceType.StopOnFailure, + 'single', + ); +} + +async function setupRedeemInstructions( + auctionView: AuctionView, + accountsByMint: Map, + accountRentExempt: number, + wallet: any, + safetyDeposit: ParsedAccount, + signers: Array, + instructions: Array, +) { + let winningPrizeSigner: Account[] = []; + let winningPrizeInstructions: TransactionInstruction[] = []; + + signers.push(winningPrizeSigner); + instructions.push(winningPrizeInstructions); + if (auctionView.myBidderMetadata) { + let newTokenAccount = accountsByMint.get( + safetyDeposit.info.tokenMint.toBase58(), + )?.pubkey; + if (!newTokenAccount) + newTokenAccount = createTokenAccount( + winningPrizeInstructions, + wallet.publicKey, + accountRentExempt, + safetyDeposit.info.tokenMint, + wallet.publicKey, + winningPrizeSigner, + ); + + await redeemBid( + auctionView.auctionManager.info.vault, + safetyDeposit.info.store, + newTokenAccount, + safetyDeposit.pubkey, + auctionView.vault.info.fractionMint, + auctionView.myBidderMetadata.info.bidderPubkey, + wallet.publicKey, + winningPrizeInstructions, + ); + } +} + +async function setupRedeemMasterInstructions( + auctionView: AuctionView, + accountsByMint: Map, + accountRentExempt: number, + wallet: any, + safetyDeposit: ParsedAccount, + item: AuctionViewItem, + signers: Array, + instructions: Array, +) { + let winningPrizeSigner: Account[] = []; + let winningPrizeInstructions: TransactionInstruction[] = []; + + signers.push(winningPrizeSigner); + instructions.push(winningPrizeInstructions); + if (auctionView.myBidderMetadata) { + let newTokenAccount = accountsByMint.get( + safetyDeposit.info.tokenMint.toBase58(), + )?.pubkey; + if (!newTokenAccount) + newTokenAccount = createTokenAccount( + winningPrizeInstructions, + wallet.publicKey, + accountRentExempt, + safetyDeposit.info.tokenMint, + wallet.publicKey, + winningPrizeSigner, + ); + + await redeemMasterEditionBid( + auctionView.auctionManager.info.vault, + safetyDeposit.info.store, + newTokenAccount, + safetyDeposit.pubkey, + auctionView.vault.info.fractionMint, + auctionView.myBidderMetadata.info.bidderPubkey, + wallet.publicKey, + winningPrizeInstructions, + item.metadata.pubkey, + await getNameSymbol(item.metadata.info), + wallet.publicKey, + ); + } +} + +async function setupRedeemLimitedInstructions( + connection: Connection, + auctionView: AuctionView, + accountsByMint: Map, + accountRentExempt: number, + mintRentExempt: number, + wallet: any, + safetyDeposit: ParsedAccount, + item: AuctionViewItem, + signers: Array, + instructions: Array, + winningConfig: WinningConfig, +) { + const updateAuth = + item.metadata.info.nonUniqueSpecificUpdateAuthority || + item.nameSymbol?.info.updateAuthority; + console.log( + 'item', + item, + item.metadata.info.mint.toBase58(), + item.metadata.info.masterEdition?.toBase58(), + ); + if (item.masterEdition && updateAuth && auctionView.myBidderMetadata) { + let newTokenAccount: PublicKey | undefined = accountsByMint.get( + item.masterEdition.info.masterMint.toBase58(), + )?.pubkey; + + if (!auctionView.myBidRedemption?.info.bidRedeemed) { + let winningPrizeSigner: Account[] = []; + let winningPrizeInstructions: TransactionInstruction[] = []; + + signers.push(winningPrizeSigner); + instructions.push(winningPrizeInstructions); + if (!newTokenAccount) + newTokenAccount = createTokenAccount( + winningPrizeInstructions, + wallet.publicKey, + accountRentExempt, + item.masterEdition.info.masterMint, + wallet.publicKey, + winningPrizeSigner, + ); + const originalAuthorityAcct = await connection.getAccountInfo( + await getOriginalAuthority( + auctionView.auction.pubkey, + item.metadata.pubkey, + ), + ); + console.log('Original auth', originalAuthorityAcct); + if (originalAuthorityAcct) { + const originalAuthority = new PublicKey( + originalAuthorityAcct.data.slice(1, 33), + ); + + await redeemLimitedEditionBid( + auctionView.auctionManager.info.vault, + safetyDeposit.info.store, + newTokenAccount, + safetyDeposit.pubkey, + auctionView.vault.info.fractionMint, + auctionView.myBidderMetadata.info.bidderPubkey, + wallet.publicKey, + winningPrizeInstructions, + originalAuthority, + item.metadata.info.mint, + item.masterEdition.info.masterMint, + ); + } + + for (let i = 0; i < winningConfig.amount; i++) { + let cashInLimitedPrizeAuthorizationTokenSigner: Account[] = []; + let cashInLimitedPrizeAuthorizationTokenInstruction: TransactionInstruction[] = []; + signers.push(cashInLimitedPrizeAuthorizationTokenSigner); + instructions.push(cashInLimitedPrizeAuthorizationTokenInstruction); + + const newLimitedEditionMint = createMint( + cashInLimitedPrizeAuthorizationTokenInstruction, + wallet.publicKey, + mintRentExempt, + 0, + wallet.publicKey, + wallet.publicKey, + cashInLimitedPrizeAuthorizationTokenSigner, + ); + const newLimitedEdition = createTokenAccount( + cashInLimitedPrizeAuthorizationTokenInstruction, + wallet.publicKey, + accountRentExempt, + newLimitedEditionMint, + wallet.publicKey, + cashInLimitedPrizeAuthorizationTokenSigner, + ); + + cashInLimitedPrizeAuthorizationTokenInstruction.push( + Token.createMintToInstruction( + programIds().token, + newLimitedEditionMint, + newLimitedEdition, + wallet.publicKey, + [], + 1, + ), + ); + + const burnAuthority = approve( + cashInLimitedPrizeAuthorizationTokenInstruction, + [], + newTokenAccount, + wallet.publicKey, + 1, + ); + + cashInLimitedPrizeAuthorizationTokenSigner.push(burnAuthority); + + mintNewEditionFromMasterEditionViaToken( + newLimitedEditionMint, + item.metadata.info.mint, + wallet.publicKey, + item.masterEdition.info.masterMint, + newTokenAccount, + burnAuthority.publicKey, + updateAuth, + cashInLimitedPrizeAuthorizationTokenInstruction, + wallet.publicKey, + ); + } + } + } +} + +async function setupRedeemOpenInstructions( + auctionView: AuctionView, + accountsByMint: Map, + accountRentExempt: number, + mintRentExempt: number, + wallet: any, + safetyDeposit: ParsedAccount, + item: AuctionViewItem, + signers: Array, + instructions: Array, +) { + const updateAuth = + item.metadata.info.nonUniqueSpecificUpdateAuthority || + item.nameSymbol?.info.updateAuthority; + if (item.masterEdition && updateAuth && auctionView.myBidderMetadata) { + let newTokenAccount: PublicKey | undefined = accountsByMint.get( + item.masterEdition.info.masterMint.toBase58(), + )?.pubkey; + + if (!auctionView.myBidRedemption?.info.bidRedeemed) { + let winningPrizeSigner: Account[] = []; + let winningPrizeInstructions: TransactionInstruction[] = []; + + signers.push(winningPrizeSigner); + instructions.push(winningPrizeInstructions); + if (!newTokenAccount) + newTokenAccount = createTokenAccount( + winningPrizeInstructions, + wallet.publicKey, + accountRentExempt, + item.masterEdition.info.masterMint, + wallet.publicKey, + winningPrizeSigner, + ); + + const transferAuthority = approve( + winningPrizeInstructions, + [], + auctionView.myBidderMetadata.info.bidderPubkey, + wallet.publicKey, + auctionView.auctionManager.info.settings.openEditionFixedPrice?.toNumber() || + 0, + ); + + winningPrizeSigner.push(transferAuthority); + + await redeemOpenEditionBid( + auctionView.auctionManager.info.vault, + safetyDeposit.info.store, + newTokenAccount, + safetyDeposit.pubkey, + auctionView.vault.info.fractionMint, + auctionView.myBidderMetadata.info.bidderPubkey, + wallet.publicKey, + winningPrizeInstructions, + item.metadata.info.mint, + item.masterEdition.info.masterMint, + transferAuthority.publicKey, + auctionView.auctionManager.info.acceptPayment, + ); + } + + if (newTokenAccount) { + let cashInOpenPrizeAuthorizationTokenSigner: Account[] = []; + let cashInOpenPrizeAuthorizationTokenInstruction: TransactionInstruction[] = []; + signers.push(cashInOpenPrizeAuthorizationTokenSigner); + instructions.push(cashInOpenPrizeAuthorizationTokenInstruction); + + const newOpenEditionMint = createMint( + cashInOpenPrizeAuthorizationTokenInstruction, + wallet.publicKey, + mintRentExempt, + 0, + wallet.publicKey, + wallet.publicKey, + cashInOpenPrizeAuthorizationTokenSigner, + ); + const newOpenEdition = createTokenAccount( + cashInOpenPrizeAuthorizationTokenInstruction, + wallet.publicKey, + accountRentExempt, + newOpenEditionMint, + wallet.publicKey, + cashInOpenPrizeAuthorizationTokenSigner, + ); + + cashInOpenPrizeAuthorizationTokenInstruction.push( + Token.createMintToInstruction( + programIds().token, + newOpenEditionMint, + newOpenEdition, + wallet.publicKey, + [], + 1, + ), + ); + + const burnAuthority = approve( + cashInOpenPrizeAuthorizationTokenInstruction, + [], + newTokenAccount, + wallet.publicKey, + 1, + ); + + cashInOpenPrizeAuthorizationTokenSigner.push(burnAuthority); + + await mintNewEditionFromMasterEditionViaToken( + newOpenEditionMint, + item.metadata.info.mint, + wallet.publicKey, + item.masterEdition.info.masterMint, + newTokenAccount, + burnAuthority.publicKey, + updateAuth, + cashInOpenPrizeAuthorizationTokenInstruction, + wallet.publicKey, + ); + } + } +} diff --git a/packages/metavinci/src/ant-custom.less b/packages/metavinci/src/ant-custom.less new file mode 100644 index 0000000..d28b8b0 --- /dev/null +++ b/packages/metavinci/src/ant-custom.less @@ -0,0 +1 @@ +@import url("https://fonts.googleapis.com/css?family=Roboto:400"); diff --git a/packages/metavinci/src/components/AppBar/index.less b/packages/metavinci/src/components/AppBar/index.less new file mode 100644 index 0000000..2e7589e --- /dev/null +++ b/packages/metavinci/src/components/AppBar/index.less @@ -0,0 +1,72 @@ +@import "_colors"; + +.App-Bar { + padding: 0px; + justify-content: space-between !important; +} + +.app-bar-box { + background: #121212; + box-shadow: 0px 6px 12px rgba(0, 0, 0, 0.3); + border-radius: 8px; + display: flex; + flex-direction: row; + align-items: center; + padding: 8px 10px; + height: 56px; + +} + +.title { + font-family: Roboto; + font-style: normal; + font-weight: 600; + font-size: 24px; + line-height: 26px; + display: flex; + align-items: center; + text-align: center; + + color: #FFFFFF; + padding: 10px 14px 10px 6px; + + margin-bottom: 0px; +} + +.divider { + border-left: 1px solid #282828; + width: 2px; + height: 40px; + margin-right: 14px; +} + +.app-btn { + font-family: Inter; + font-style: normal; + font-weight: normal; + font-size: 16px; + line-height: 19px; + border-width: 0px; +} + +.app-bar-inner { + display: flex; + min-width: 50%; + justify-content: center; + position: relative; + height: auto; + .app-bar-item { + cursor: pointer; + padding: 0 30px; + color: @tungsten-60; + font-size: 18px; + a { + color: inherit; + } + &.active { + color: white; + } + } +} + + diff --git a/packages/metavinci/src/components/AppBar/index.tsx b/packages/metavinci/src/components/AppBar/index.tsx new file mode 100644 index 0000000..df7220a --- /dev/null +++ b/packages/metavinci/src/components/AppBar/index.tsx @@ -0,0 +1,48 @@ +import React from 'react'; +import './index.less'; +import { Link, useLocation } from 'react-router-dom'; +import { Button } from 'antd'; +import { ConnectButton, CurrentUserBadge, useWallet } from '@oyster/common'; + +const UserActions = () => { + return <> + + + + + + + + ; +} + +export const AppBar = () => { + const location = useLocation(); + const { connected } = useWallet(); + + const isRoot = location.pathname === '/'; + + + return ( + <> +
+

M

+
+ + + + + + + + + +
+ {!connected && } + {connected &&
+ + +
} + + ); +}; diff --git a/packages/metavinci/src/components/AppBar/searchBox.less b/packages/metavinci/src/components/AppBar/searchBox.less new file mode 100644 index 0000000..282110a --- /dev/null +++ b/packages/metavinci/src/components/AppBar/searchBox.less @@ -0,0 +1,7 @@ +.search-btn { + background: #FFFFFF; + border-width: 0px; + box-shadow: 0px 2px 6px rgba(0, 0, 0, 0.1); + width: 44px; + height: 44px; +} diff --git a/packages/metavinci/src/components/AppBar/searchBox.tsx b/packages/metavinci/src/components/AppBar/searchBox.tsx new file mode 100644 index 0000000..152ac06 --- /dev/null +++ b/packages/metavinci/src/components/AppBar/searchBox.tsx @@ -0,0 +1,18 @@ +import React from 'react'; +import { Input } from 'antd'; +import { SearchOutlined } from '@ant-design/icons'; +import { Button } from 'antd'; +import './searchBox.less'; + +const { Search } = Input; + +export const SearchBox = ({}) => { + return ; + + const onSearch = (value: string) => console.log(value); + + return ; +} diff --git a/packages/metavinci/src/components/ArtCard/index.less b/packages/metavinci/src/components/ArtCard/index.less new file mode 100644 index 0000000..e8c9a97 --- /dev/null +++ b/packages/metavinci/src/components/ArtCard/index.less @@ -0,0 +1,63 @@ + +.art-card { + min-width: 200px; + margin-top: 30px; + filter: drop-shadow(0px 2px 6px rgba(0, 0, 0, 0.1)); + border-radius: 8px; + overflow: hidden; + + .ant-card-body { + display: flex; + flex-direction: row; + align-items: flex-start; + padding: 0; + text-align: left; + + /* gradients/metal */ + background: #282828; + box-shadow: inset 0px 4px 20px rgba(0, 0, 0, 0.3); + border-radius: 0px 0px 8px 8px; + } + + .ant-card-cover { + min-height: 200px; + } + + .ant-card-meta-title { + font-family: Inter; + font-size: 20px; + font-weight: 600; + padding: 24px 24px 0 24px; + } + + .ant-card-meta { + width: 100%; + } + +} + +.ant-avatar.ant-avatar-circle { + margin-left: 24px; +} + +.small { + max-width: 300px; + margin-left: auto; + margin-right: auto; +} + +.cd-container { + background: linear-gradient(270deg, #616774 7.29%, #403F4C 100%); + box-shadow: inset 0px 4px 20px rgba(0, 0, 0, 0.3); + border-radius: 0px 0px 8px 8px; + margin-top: 20px; + padding: 24px; +} + +.cd-title { + color: rgba(255, 255, 255, 0.7); +} + +.cd-time { + color: white; +} diff --git a/packages/metavinci/src/components/ArtCard/index.tsx b/packages/metavinci/src/components/ArtCard/index.tsx new file mode 100644 index 0000000..618e570 --- /dev/null +++ b/packages/metavinci/src/components/ArtCard/index.tsx @@ -0,0 +1,83 @@ +import React, { useEffect, useState } from 'react'; +import { Card, Avatar, CardProps, Button } from 'antd'; +import { MetadataCategory } from '@oyster/common'; +import { ArtContent } from './../ArtContent'; +import './index.less'; +import { getCountdown } from '../../utils/utils'; +import { useArt } from '../../hooks'; +import { PublicKey } from '@solana/web3.js'; + +const { Meta } = Card; + +export interface ArtCardProps extends CardProps { + pubkey?: PublicKey; + image?: string; + category?: MetadataCategory + name?: string; + symbol?: string; + description?: string; + artist?: string; + preview?: boolean; + small?: boolean; + close?: () => void; + endAuctionAt?: number; +} + +export const ArtCard = (props: ArtCardProps) => { + let { className, small, category, image, name, preview, artist, description, close, pubkey, endAuctionAt, ...rest } = props; + const art = useArt(pubkey); + category = art?.category || category; + image = art?.image || image; + name = art?.title || name || ''; + artist = art?.artist || artist; + description = art?.about || description; + + const [hours, setHours] = useState(23) + const [minutes, setMinutes] = useState(59) + const [seconds, setSeconds] = useState(59) + + useEffect(() => { + const interval = setInterval(() => { + if (!endAuctionAt) return + const { hours, minutes, seconds } = getCountdown(endAuctionAt) + + setHours(hours) + setMinutes(minutes) + setSeconds(seconds) + }, 1000) + return () => clearInterval(interval) + }, []) + + return ( + + {close && } + + } + {...rest} + > + + {artist} + {endAuctionAt && +
+ {(hours == 0 && minutes == 0 && seconds == 0) ? +
Finished
+ : <> +
Ending in
+
{hours}h {minutes}m {seconds}s
+ } +
+ } +
} + /> + + ); +}; diff --git a/packages/metavinci/src/components/ArtContent/index.tsx b/packages/metavinci/src/components/ArtContent/index.tsx new file mode 100644 index 0000000..984c2d4 --- /dev/null +++ b/packages/metavinci/src/components/ArtContent/index.tsx @@ -0,0 +1,28 @@ +import React, { useMemo } from 'react'; +import { Image } from 'antd'; +import { MetadataCategory } from '@oyster/common' + +export const ArtContent = ({ + content, + category, + className, + preview + }: { + category?: MetadataCategory, + content?: string, + className?: string, + preview?: boolean, + }) => { + return category === 'video' ? +
+
{days}
+
days
+ } + +
{hours}
+
hours
+ + +
{minutes}
+
minutes
+ + {!days && +
{seconds}
+
seconds
+ } + + } +
+
+ Any bids placed in the last 15 minutes will extend the auction for + another 15 minutes. +
+
+ +
+ + + +
+ Your Balance: $ + {myPayingAccount ? myPayingAccount.info.amount.toNumber() : 0.0} +
+ + {auctionView.state == AuctionViewState.Ended ? ( + + ) : ( + + )} + +
+ ); +}; + +export const AuctionBids = ({ bids }: { bids: ParsedAccount[] }) => { + return ( + + {bids.map((bid, index) => { + const bidder = bid.info.bidderPubkey.toBase58(); + return ( + + {index + 1}. + {shortenAddress(bidder)} + {bid.info.lastBid.toString()} + + ); + })} + + ); +}; diff --git a/packages/metavinci/src/components/Confetti/index.tsx b/packages/metavinci/src/components/Confetti/index.tsx new file mode 100644 index 0000000..3c9ae56 --- /dev/null +++ b/packages/metavinci/src/components/Confetti/index.tsx @@ -0,0 +1,53 @@ +import React, { useEffect, useState } from "react"; + +interface Particle { + top: number, + left: number, + speed: number, + angle: number, + angle_speed: number, + size: number, +} + +export const Confetti = () => { + const [particles, setParticles] = useState>(Array.from({ length: 30 }).map(_ => ({ + top: -Math.random() * 100, + left: Math.random() * 100, + speed: Math.random() * 1 + 3, + angle: 0, + angle_speed: Math.random() * 10 + 5, + size: Math.floor(Math.random() * 8 + 12), + }))) + + useEffect(() => { + const interval = setInterval(() => { + setParticles(parts => parts.map(part => ({ + ...part, + top: (part.top > 130 ? -30 : part.top + part.speed), + angle: (part.angle > 360 ? 0 : part.angle + part.angle_speed), + }))) + }, 70); + + const timeout = setTimeout(() => { + setParticles([]); + clearInterval(interval); + }, 5000); + + return () => { + clearInterval(interval); + clearTimeout(timeout); + }; + }, []) + + const getStyle = (particle: Particle) => ({ + top: `${particle.top}%`, + left: `${particle.left}%`, + transform: `rotate(${particle.angle}deg)`, + width: particle.size, + height: particle.size, + }) + + return
+ {particles.map((particle, idx) => )} +
+} diff --git a/packages/metavinci/src/components/Footer/index.less b/packages/metavinci/src/components/Footer/index.less new file mode 100644 index 0000000..611183b --- /dev/null +++ b/packages/metavinci/src/components/Footer/index.less @@ -0,0 +1,3 @@ +.footer { + margin: 20px 0 20px 0; +} diff --git a/packages/metavinci/src/components/Footer/index.tsx b/packages/metavinci/src/components/Footer/index.tsx new file mode 100644 index 0000000..e1bdecf --- /dev/null +++ b/packages/metavinci/src/components/Footer/index.tsx @@ -0,0 +1,25 @@ +import React from 'react'; +import { GithubOutlined, TwitterOutlined } from '@ant-design/icons'; +import { Button } from 'antd'; + +import './index.less'; + +export const Footer = () => { + return ( +
+ + +
+ ); +}; diff --git a/packages/metavinci/src/components/Layout/index.less b/packages/metavinci/src/components/Layout/index.less new file mode 100644 index 0000000..d979bf5 --- /dev/null +++ b/packages/metavinci/src/components/Layout/index.less @@ -0,0 +1,17 @@ +.metamask-icon { + background-position: 50%; + background-repeat: no-repeat; + background-image: url(/assets/metamask.svg); +} + +.app-left { + align-items: center; + display: flex; + flex-direction: row; +} +.app-right { + align-items: center; + display: flex; + flex-direction: row; + +} diff --git a/packages/metavinci/src/components/Layout/index.tsx b/packages/metavinci/src/components/Layout/index.tsx new file mode 100644 index 0000000..158e232 --- /dev/null +++ b/packages/metavinci/src/components/Layout/index.tsx @@ -0,0 +1,27 @@ +import React from 'react'; +import { Layout } from 'antd'; + +import './../../App.less'; +import './index.less'; +import { LABELS } from '../../constants'; +import { AppBar } from '../AppBar'; + +const { Header, Content, Footer } = Layout; + +export const AppLayout = React.memo((props: any) => { + + return ( + <> +
+ +
+ +
+ + {props.children} + +
+
+ + ); +}); diff --git a/packages/metavinci/src/components/MainAuctionCard/index.less b/packages/metavinci/src/components/MainAuctionCard/index.less new file mode 100644 index 0000000..b2f7af9 --- /dev/null +++ b/packages/metavinci/src/components/MainAuctionCard/index.less @@ -0,0 +1,44 @@ + +.main-auction-container { + background-size: cover; + background-repeat: no-repeat; + background-position-y: center; + min-height: 300px; + margin-bottom: 1rem; + border-radius: 4px; +} + +.main-auction-inner { + width: 230px; + height: 200px; + background: rgba(0, 0, 0, 0.64); + backdrop-filter: blur(48px); + position: absolute; + top: 20px; + left: 20px; + text-align: left; + padding: 0.7rem; + display: flex; + flex-direction: column; +} + +.main-auction-title { + font-weight: 500; + font-size: 1.7rem; +} + +.main-auction-auctioner { + font-size: 1.2rem; + line-height: 2rem; +} + +.main-auction-bid { + font-size: 0.9rem; + margin-top: auto; + font-weight: 100; +} + +.main-auction-details { + background-color: #722ED1; + margin-top: auto; +} diff --git a/packages/metavinci/src/components/MainAuctionCard/index.tsx b/packages/metavinci/src/components/MainAuctionCard/index.tsx new file mode 100644 index 0000000..4265e70 --- /dev/null +++ b/packages/metavinci/src/components/MainAuctionCard/index.tsx @@ -0,0 +1,20 @@ +import React from 'react' +import { Link } from 'react-router-dom' +import { Button } from 'antd' + +import { Auction } from '../../types/index' + +import './index.less' + +export const MainAuctionCard = ({ auction }: { auction: Auction }) => { + return
+
+
{auction.name}
+ +
Highest Bid: ${auction.highestBid} / â—Ž{auction.solAmt}
+ +
+
+} diff --git a/packages/metavinci/src/components/PreSaleBanner/index.less b/packages/metavinci/src/components/PreSaleBanner/index.less new file mode 100644 index 0000000..3ceb343 --- /dev/null +++ b/packages/metavinci/src/components/PreSaleBanner/index.less @@ -0,0 +1,26 @@ + +.presale-container { + // background-size: cover; + background-position-x: right; + background-color: #B29995; + background-repeat: no-repeat; + background-position-y: center; + min-height: 200px; + margin-bottom: 1rem; + border-radius: 4px; + color: black; +} + +.presale-title { + font-weight: bolder; + font-size: 1.7rem; +} + +.presale-product { + font-size: 1.7rem; +} + +.cd-number { + font-size: 1.4rem; + font-weight: 700; +} diff --git a/packages/metavinci/src/components/PreSaleBanner/index.tsx b/packages/metavinci/src/components/PreSaleBanner/index.tsx new file mode 100644 index 0000000..12678bd --- /dev/null +++ b/packages/metavinci/src/components/PreSaleBanner/index.tsx @@ -0,0 +1,58 @@ +import React, { useEffect, useState } from 'react' +import { Link } from 'react-router-dom' +import { Col, Row } from 'antd' + +import './index.less' +import { getCountdown } from '../../utils/utils' + +interface IPreSaleBanner { + artistName: string, + productName: string, + preSaleTS: number, + image: string, +} + +export const PreSaleBanner = ({ artistName, productName, preSaleTS, image }: IPreSaleBanner) => { + const [days, setDays] = useState(99) + const [hours, setHours] = useState(23) + const [minutes, setMinutes] = useState(59) + + useEffect(() => { + const interval = setInterval(() => { + const { days, hours, minutes } = getCountdown(preSaleTS) + + setDays(days) + setHours(hours) + setMinutes(minutes) + }, 1000) + return () => clearInterval(interval) + }, []) + + return ( +
+ +
+
+
{artistName}
+
{productName}
+
COUNTDOWN TO PRE-SALE
+ +
+
{days}
+
days
+ + +
{hours}
+
hours
+ + +
{minutes}
+
minutes
+ + + + + + + ) +} diff --git a/packages/metavinci/src/components/Settings/index.tsx b/packages/metavinci/src/components/Settings/index.tsx new file mode 100644 index 0000000..542881d --- /dev/null +++ b/packages/metavinci/src/components/Settings/index.tsx @@ -0,0 +1,35 @@ +import React from 'react'; +import { Button, Select } from 'antd'; +import { contexts } from '@oyster/common'; + +const { useWallet, WALLET_PROVIDERS } = contexts.Wallet; +const { ENDPOINTS, useConnectionConfig } = contexts.Connection; + +export const Settings = () => { + const { connected, disconnect } = useWallet(); + const { endpoint, setEndpoint } = useConnectionConfig(); + + return ( + <> +
+ Network:{' '} + + {connected && ( + + )} +
+ + ); +}; diff --git a/packages/metavinci/src/components/UserSearch/index.tsx b/packages/metavinci/src/components/UserSearch/index.tsx new file mode 100644 index 0000000..6a0f660 --- /dev/null +++ b/packages/metavinci/src/components/UserSearch/index.tsx @@ -0,0 +1,93 @@ +import { Select, Spin } from 'antd'; +import { SelectProps } from 'antd/es/select'; +import debounce from 'lodash/debounce'; +import React, { useMemo, useRef, useState } from 'react'; +import './styles.less'; + +export interface DebounceSelectProps + extends Omit, 'options' | 'children'> { + fetchOptions: (search: string) => Promise; + debounceTimeout?: number; +} + +function DebounceSelect< + ValueType extends { key?: string; label: React.ReactNode; value: string | number } = any +>({ fetchOptions, debounceTimeout = 800, ...props }: DebounceSelectProps) { + const [fetching, setFetching] = useState(false); + const [options, setOptions] = useState([]); + const fetchRef = useRef(0); + + const debounceFetcher = useMemo(() => { + const loadOptions = (value: string) => { + fetchRef.current += 1; + const fetchId = fetchRef.current; + setOptions([]); + setFetching(true); + + fetchOptions(value).then(newOptions => { + if (fetchId !== fetchRef.current) { + // for fetch callback order + return; + } + + setOptions(newOptions); + setFetching(false); + }); + }; + + return debounce(loadOptions, debounceTimeout); + }, [fetchOptions, debounceTimeout]); + + return ( + + labelInValue + filterOption={false} + onSearch={debounceFetcher} + notFoundContent={fetching ? : null} + {...props} + options={options} + /> + ); +} + +// Usage of DebounceSelect +export interface UserValue { + key: string; + label: string; + value: string; +} + +async function fetchUserList(username: string): Promise { + console.log('fetching user', username); + + return fetch('https://randomuser.me/api/?results=5') + .then(response => response.json()) + .then(body => + body.results.map( + (user: { name: { first: string; last: string }; login: { username: string } }) => ({ + label: `${user.name.first} ${user.name.last}`, + value: user.login.username, + }), + ), + ); +} + +export const UserSearch = (props: {setCreators: Function}) => { + const [value, setValue] = React.useState([]); + + return ( + { + props.setCreators(newValue) + setValue(newValue); + }} + style={{ width: '100%' }} + /> + ); +}; diff --git a/packages/metavinci/src/components/UserSearch/styles.less b/packages/metavinci/src/components/UserSearch/styles.less new file mode 100644 index 0000000..69c5f23 --- /dev/null +++ b/packages/metavinci/src/components/UserSearch/styles.less @@ -0,0 +1,11 @@ +.user-selector { + background: #282828; + border-radius: 8px; + padding: 3px 0px; + overflow: hidden; + + .ant-select-selector { + border-width: 0px !important; + text-align: left; + } +} diff --git a/packages/metavinci/src/constants/index.tsx b/packages/metavinci/src/constants/index.tsx new file mode 100644 index 0000000..b6c11ec --- /dev/null +++ b/packages/metavinci/src/constants/index.tsx @@ -0,0 +1,2 @@ +export * from './labels'; +export * from './style'; diff --git a/packages/metavinci/src/constants/labels.ts b/packages/metavinci/src/constants/labels.ts new file mode 100644 index 0000000..95e8fb8 --- /dev/null +++ b/packages/metavinci/src/constants/labels.ts @@ -0,0 +1,19 @@ +export const LABELS = { + CONNECT_LABEL: 'Connect Wallet', + GIVE_SOL: 'Give me SOL', + FAUCET_INFO: + 'This faucet will help you fund your accounts outside of Solana main network.', + ACCOUNT_FUNDED: 'Account funded.', + MENU_HOME: 'Home', + MENU_FAUCET: 'Faucet', + APP_TITLE: 'Metaplex', + CONNECT_BUTTON: 'Connect', + WALLET_TOOLTIP: 'Wallet public key', + WALLET_BALANCE: 'Wallet balance', + SETTINGS_TOOLTIP: 'Settings', + GO_BACK_ACTION: 'Go back', + TOTAL_TITLE: 'Total', + ENTER_AMOUNT: 'Enter an amount', + TRANSFER: 'Transfer', + SET_CORRECT_WALLET_NETWORK: 'Set correct wallet network', +}; diff --git a/packages/metavinci/src/constants/style.tsx b/packages/metavinci/src/constants/style.tsx new file mode 100644 index 0000000..3818b89 --- /dev/null +++ b/packages/metavinci/src/constants/style.tsx @@ -0,0 +1,5 @@ +export const GUTTER = [16, { xs: 8, sm: 16, md: 16, lg: 16 }] as any; + +export const SMALL_STATISTIC: React.CSSProperties = { + fontSize: 10, +}; diff --git a/packages/metavinci/src/contexts/coingecko.tsx b/packages/metavinci/src/contexts/coingecko.tsx new file mode 100644 index 0000000..6519d90 --- /dev/null +++ b/packages/metavinci/src/contexts/coingecko.tsx @@ -0,0 +1,49 @@ +import { EventEmitter } from '@oyster/common'; +import React, { useContext, useEffect, useState } from 'react'; +import { MarketsContextState } from './market'; + +export const COINGECKO_POOL_INTERVAL = 1000 * 30; // 30 sec +export const COINGECKO_API = 'https://api.coingecko.com/api/v3/'; +export const COINGECKO_COIN_LIST_API = `${COINGECKO_API}coins/list`; +export const COINGECKO_COIN_PRICE_API = `${COINGECKO_API}simple/price`; + +interface CoinInfo { + id: string; + symbol: string; + name: string; +} + +export interface CoingeckoContextState { + coinList: Map; +} + +const CoingeckoContext = React.createContext( + null, +); +export function CoingeckoProvider({ children = null as any }) { + const [coinList, setCoinList] = useState>(new Map()); + + useEffect(() => { + (async () => { + const listResponse = await fetch(COINGECKO_COIN_LIST_API); + const coinList: CoinInfo[] = await listResponse.json(); + setCoinList( + coinList.reduce((coins, val) => { + coins.set(val.symbol, val); + return coins; + }, new Map()), + ); + })(); + }, [setCoinList]); + + return ( + + {children} + + ); +} + +export const useCoingecko = () => { + const context = useContext(CoingeckoContext); + return context as CoingeckoContextState; +}; diff --git a/packages/metavinci/src/contexts/index.tsx b/packages/metavinci/src/contexts/index.tsx new file mode 100644 index 0000000..4151a68 --- /dev/null +++ b/packages/metavinci/src/contexts/index.tsx @@ -0,0 +1,2 @@ +export * from './market'; +export * from './meta'; diff --git a/packages/metavinci/src/contexts/market.tsx b/packages/metavinci/src/contexts/market.tsx new file mode 100644 index 0000000..6a8e10e --- /dev/null +++ b/packages/metavinci/src/contexts/market.tsx @@ -0,0 +1,365 @@ +import React, { useCallback, useContext, useEffect, useState } from 'react'; + +import { Market, MARKETS, Orderbook, TOKEN_MINTS } from '@project-serum/serum'; +import { AccountInfo, Connection, PublicKey } from '@solana/web3.js'; +import { useMemo } from 'react'; + +import { + contexts, + utils, + EventEmitter, +} from '@oyster/common'; + +import { DexMarketParser } from './../models/dex'; +import { MINT_TO_MARKET } from '../models/marketOverrides'; +const { useConnectionConfig } = contexts.Connection; +const { convert, fromLamports, getTokenName, STABLE_COINS } = utils; +const { cache, getMultipleAccounts } = contexts.Accounts; + +const INITAL_LIQUIDITY_DATE = new Date('2020-10-27'); +export const BONFIDA_POOL_INTERVAL = 30 * 60_000; // 30 min + +interface RecentPoolData { + pool_identifier: string; + volume24hA: number; +} + +export interface MarketsContextState { + midPriceInUSD: (mint: string) => number; + marketEmitter: EventEmitter; + accountsToObserve: Map; + marketByMint: Map; + + subscribeToMarket: (mint: string) => () => void; + + precacheMarkets: (mints: string[]) => void; + dailyVolume: Map; +} + +const REFRESH_INTERVAL = 30_000; + +const MarketsContext = React.createContext(null); + +const marketEmitter = new EventEmitter(); + +export function MarketProvider({ children = null as any }) { + const { endpoint } = useConnectionConfig(); + const accountsToObserve = useMemo(() => new Map(), []); + const [marketMints, setMarketMints] = useState([]); + const [dailyVolume, setDailyVolume] = useState>( + new Map(), + ); + + const connection = useMemo(() => new Connection(endpoint, 'recent'), [ + endpoint, + ]); + + const marketByMint = useMemo(() => { + return [...new Set(marketMints).values()].reduce((acc, key) => { + const mintAddress = key; + + const SERUM_TOKEN = TOKEN_MINTS.find( + a => a.address.toBase58() === mintAddress, + ); + + const marketAddress = MINT_TO_MARKET[mintAddress]; + const marketName = `${SERUM_TOKEN?.name}/USDC`; + const marketInfo = MARKETS.find( + m => m.name === marketName || m.address.toBase58() === marketAddress, + ); + + if (marketInfo) { + acc.set(mintAddress, { + marketInfo, + }); + } + + return acc; + }, new Map()) as Map; + }, [marketMints]); + + useEffect(() => { + let timer = 0; + + const updateData = async () => { + await refreshAccounts(connection, [...accountsToObserve.keys()]); + marketEmitter.raiseMarketUpdated(new Set([...marketByMint.keys()])); + + timer = window.setTimeout(() => updateData(), REFRESH_INTERVAL); + }; + + const initalQuery = async () => { + const reverseSerumMarketCache = new Map(); + [...marketByMint.keys()].forEach(mint => { + const m = marketByMint.get(mint); + if (m) { + reverseSerumMarketCache.set(m.marketInfo.address.toBase58(), mint); + } + }); + + const allMarkets = [...marketByMint.values()].map(m => { + return m.marketInfo.address.toBase58(); + }); + + await getMultipleAccounts( + connection, + // only query for markets that are not in cahce + allMarkets.filter(a => cache.get(a) === undefined), + 'single', + ).then(({ keys, array }) => { + allMarkets.forEach(() => {}); + + return array.map((item, index) => { + const marketAddress = keys[index]; + const mintAddress = reverseSerumMarketCache.get(marketAddress); + if (mintAddress) { + const market = marketByMint.get(mintAddress); + + if (market) { + const id = market.marketInfo.address; + cache.add(id, item, DexMarketParser); + } + } + + return item; + }); + }); + + const toQuery = new Set(); + allMarkets.forEach(m => { + const market = cache.get(m); + if (!market) { + return; + } + + const decoded = market; + + if (!cache.get(decoded.info.baseMint)) { + toQuery.add(decoded.info.baseMint.toBase58()); + } + + if (!cache.get(decoded.info.baseMint)) { + toQuery.add(decoded.info.quoteMint.toBase58()); + } + + toQuery.add(decoded.info.bids.toBase58()); + toQuery.add(decoded.info.asks.toBase58()); + }); + + await refreshAccounts(connection, [...toQuery.keys()]); + + marketEmitter.raiseMarketUpdated(new Set([...marketByMint.keys()])); + + // start update loop + updateData(); + }; + + initalQuery(); + + return () => { + window.clearTimeout(timer); + }; + }, [marketByMint, accountsToObserve, connection]); + + const midPriceInUSD = useCallback( + (mintAddress: string) => { + return getMidPrice( + marketByMint.get(mintAddress)?.marketInfo.address.toBase58(), + mintAddress, + ); + }, + [marketByMint], + ); + + const subscribeToMarket = useCallback( + (mintAddress: string) => { + const info = marketByMint.get(mintAddress); + const market = cache.get(info?.marketInfo.address.toBase58() || ''); + if (!market) { + return () => {}; + } + + // TODO: get recent volume + + const bid = market.info.bids.toBase58(); + const ask = market.info.asks.toBase58(); + accountsToObserve.set(bid, (accountsToObserve.get(bid) || 0) + 1); + accountsToObserve.set(ask, (accountsToObserve.get(ask) || 0) + 1); + + // TODO: add event queue to query for last trade + + return () => { + accountsToObserve.set(bid, (accountsToObserve.get(bid) || 0) - 1); + accountsToObserve.set(ask, (accountsToObserve.get(ask) || 0) - 1); + + // cleanup + [...accountsToObserve.keys()].forEach(key => { + if ((accountsToObserve.get(key) || 0) <= 0) { + accountsToObserve.delete(key); + } + }); + }; + }, + [marketByMint, accountsToObserve], + ); + + const precacheMarkets = useCallback( + (mints: string[]) => { + const newMints = [...new Set([...marketMints, ...mints]).values()]; + + if (marketMints.length !== newMints.length) { + setMarketMints(newMints); + } + }, + [setMarketMints, marketMints], + ); + + return ( + + {children} + + ); +} + +export const useMarkets = () => { + const context = useContext(MarketsContext); + return context as MarketsContextState; +}; + +export const useMidPriceInUSD = (mint: string) => { + const { midPriceInUSD, subscribeToMarket, marketEmitter } = useContext( + MarketsContext, + ) as MarketsContextState; + const [price, setPrice] = useState(0); + + useEffect(() => { + let subscription = subscribeToMarket(mint); + const update = () => { + if (midPriceInUSD) { + setPrice(midPriceInUSD(mint)); + } + }; + + update(); + const dispose = marketEmitter.onMarket(update); + + return () => { + subscription(); + dispose(); + }; + }, [midPriceInUSD, mint, marketEmitter, subscribeToMarket]); + + return { price, isBase: price === 1.0 }; +}; + +export const usePrecacheMarket = () => { + const context = useMarkets(); + return context.precacheMarkets; +}; + +const bbo = (bidsBook: Orderbook, asksBook: Orderbook) => { + const bestBid = bidsBook.getL2(1); + const bestAsk = asksBook.getL2(1); + + if (bestBid.length > 0 && bestAsk.length > 0) { + return (bestBid[0][0] + bestAsk[0][0]) / 2.0; + } + + return 0; +}; + +const getMidPrice = (marketAddress?: string, mintAddress?: string) => { + const SERUM_TOKEN = TOKEN_MINTS.find( + a => a.address.toBase58() === mintAddress, + ); + + if (STABLE_COINS.has(SERUM_TOKEN?.name || '')) { + return 1.0; + } + + if (!marketAddress) { + return 0.0; + } + + const marketInfo = cache.get(marketAddress); + if (!marketInfo) { + return 0.0; + } + + const decodedMarket = marketInfo.info; + + const baseMintDecimals = + cache.get(decodedMarket.baseMint)?.info.decimals || 0; + const quoteMintDecimals = + cache.get(decodedMarket.quoteMint)?.info.decimals || 0; + + const market = new Market( + decodedMarket, + baseMintDecimals, + quoteMintDecimals, + undefined, + decodedMarket.programId, + ); + + const bids = cache.get(decodedMarket.bids)?.info; + const asks = cache.get(decodedMarket.asks)?.info; + + if (bids && asks) { + const bidsBook = new Orderbook(market, bids.accountFlags, bids.slab); + const asksBook = new Orderbook(market, asks.accountFlags, asks.slab); + + return bbo(bidsBook, asksBook); + } + + return 0; +}; + +const refreshAccounts = async (connection: Connection, keys: string[]) => { + if (keys.length === 0) { + return []; + } + + return getMultipleAccounts(connection, keys, 'single').then( + ({ keys, array }) => { + return array.map((item, index) => { + const address = keys[index]; + return cache.add(new PublicKey(address), item); + }); + }, + ); +}; + +interface SerumMarket { + marketInfo: { + address: PublicKey; + name: string; + programId: PublicKey; + deprecated: boolean; + }; + + // 1st query + marketAccount?: AccountInfo; + + // 2nd query + mintBase?: AccountInfo; + mintQuote?: AccountInfo; + bidAccount?: AccountInfo; + askAccount?: AccountInfo; + eventQueue?: AccountInfo; + + swap?: { + dailyVolume: number; + }; + + midPrice?: (mint?: PublicKey) => number; +} diff --git a/packages/metavinci/src/contexts/meta.tsx b/packages/metavinci/src/contexts/meta.tsx new file mode 100644 index 0000000..bae6a43 --- /dev/null +++ b/packages/metavinci/src/contexts/meta.tsx @@ -0,0 +1,556 @@ +import { + EventEmitter, + programIds, + useConnection, + decodeMetadata, + decodeNameSymbolTuple, + AuctionParser, + decodeEdition, + decodeMasterEdition, + Metadata, + getMultipleAccounts, + cache, + MintParser, + ParsedAccount, + actions, + Edition, + MasterEdition, + NameSymbolTuple, + AuctionData, + SafetyDepositBox, + VaultKey, + decodeSafetyDeposit, + BidderMetadata, + BidderMetadataParser, + BidderPot, + BidderPotParser, + BIDDER_METADATA_LEN, + BIDDER_POT_LEN, + decodeVault, + Vault, + TokenAccount, + useUserAccounts, +} from '@oyster/common'; +import { MintInfo } from '@solana/spl-token'; +import { Connection, PublicKey, PublicKeyAndAccount } from '@solana/web3.js'; +import BN from 'bn.js'; +import React, { useContext, useEffect, useState } from 'react'; +import { + AuctionManager, + AuctionManagerStatus, + BidRedemptionTicket, + decodeAuctionManager, + decodeBidRedemptionTicket, + getAuctionManagerKey, + getBidderKeys, + MetaplexKey, +} from '../models/metaplex'; + +const { MetadataKey } = actions; +export interface MetaContextState { + metadata: ParsedAccount[]; + metadataByMint: Record>; + nameSymbolTuples: Record>; + editions: Record>; + masterEditions: Record>; + auctionManagers: Record>; + auctions: Record>; + vaults: Record>; + bidderMetadataByAuctionAndBidder: Record< + string, + ParsedAccount + >; + safetyDepositBoxesByVaultAndIndex: Record< + string, + ParsedAccount + >; + bidderPotsByAuctionAndBidder: Record>; + bidRedemptions: Record>; +} + +const MetaContext = React.createContext({ + metadata: [], + metadataByMint: {}, + nameSymbolTuples: {}, + masterEditions: {}, + editions: {}, + auctionManagers: {}, + auctions: {}, + vaults: {}, + bidderMetadataByAuctionAndBidder: {}, + safetyDepositBoxesByVaultAndIndex: {}, + bidderPotsByAuctionAndBidder: {}, + bidRedemptions: {}, +}); + +export function MetaProvider({ children = null as any }) { + const connection = useConnection(); + const { userAccounts } = useUserAccounts(); + const accountByMint = userAccounts.reduce((prev, acc) => { + prev.set(acc.info.mint.toBase58(), acc); + return prev; + }, new Map()); + + const [metadata, setMetadata] = useState[]>([]); + const [metadataByMint, setMetadataByMint] = useState< + Record> + >({}); + const [nameSymbolTuples, setNameSymbolTuples] = useState< + Record> + >({}); + const [masterEditions, setMasterEditions] = useState< + Record> + >({}); + const [editions, setEditions] = useState< + Record> + >({}); + const [auctionManagers, setAuctionManagers] = useState< + Record> + >({}); + const [bidRedemptions, setBidRedemptions] = useState< + Record> + >({}); + const [auctions, setAuctions] = useState< + Record> + >({}); + const [vaults, setVaults] = useState>>( + {}, + ); + + const [ + bidderMetadataByAuctionAndBidder, + setBidderMetadataByAuctionAndBidder, + ] = useState>>({}); + const [ + bidderPotsByAuctionAndBidder, + setBidderPotsByAuctionAndBidder, + ] = useState>>({}); + const [ + safetyDepositBoxesByVaultAndIndex, + setSafetyDepositBoxesByVaultAndIndex, + ] = useState>>({}); + + useEffect(() => { + + }); + + useEffect(() => { + let dispose = () => {}; + (async () => { + const processAuctions = async (a: PublicKeyAndAccount) => { + try { + const account = cache.add( + a.pubkey, + a.account, + AuctionParser, + ) as ParsedAccount; + + account.info.auctionManagerKey = await getAuctionManagerKey( + account.info.resource, + a.pubkey, + ); + const payerAcct = accountByMint.get( + account.info.tokenMint.toBase58(), + ); + if (payerAcct) + account.info.bidRedemptionKey = ( + await getBidderKeys(a.pubkey, payerAcct.pubkey) + ).bidRedemption; + setAuctions(e => ({ + ...e, + [a.pubkey.toBase58()]: account, + })); + } catch { + // ignore errors + // add type as first byte for easier deserialization + } + + try { + if (a.account.data.length == BIDDER_METADATA_LEN) { + const account = cache.add( + a.pubkey, + a.account, + BidderMetadataParser, + ) as ParsedAccount; + + setBidderMetadataByAuctionAndBidder(e => ({ + ...e, + [account.info.auctionPubkey.toBase58() + + '-' + + account.info.bidderPubkey.toBase58()]: account, + })); + } + } catch { + // ignore errors + // add type as first byte for easier deserialization + } + try { + if (a.account.data.length == BIDDER_POT_LEN) { + const account = cache.add( + a.pubkey, + a.account, + BidderPotParser, + ) as ParsedAccount; + + setBidderPotsByAuctionAndBidder(e => ({ + ...e, + [account.info.auctionAct.toBase58() + + '-' + + account.info.bidderAct.toBase58()]: account, + })); + } + } catch { + // ignore errors + // add type as first byte for easier deserialization + } + }; + + const accounts = await connection.getProgramAccounts( + programIds().auction, + ); + for (let i = 0; i < accounts.length; i++) { + await processAuctions(accounts[i]); + } + + let subId = connection.onProgramAccountChange( + programIds().auction, + async info => { + const pubkey = + typeof info.accountId === 'string' + ? new PublicKey((info.accountId as unknown) as string) + : info.accountId; + await processAuctions({ + pubkey, + account: info.accountInfo, + }); + }, + ); + dispose = () => { + connection.removeProgramAccountChangeListener(subId); + }; + })(); + + return () => { + dispose(); + }; + }, [connection, setAuctions, userAccounts]); + + useEffect(() => { + let dispose = () => {}; + (async () => { + const processVaultData = async (a: PublicKeyAndAccount) => { + try { + if (a.account.data[0] == VaultKey.SafetyDepositBoxV1) { + const safetyDeposit = await decodeSafetyDeposit(a.account.data); + const account: ParsedAccount = { + pubkey: a.pubkey, + account: a.account, + info: safetyDeposit, + }; + setSafetyDepositBoxesByVaultAndIndex(e => ({ + ...e, + [safetyDeposit.vault.toBase58() + + '-' + + safetyDeposit.order]: account, + })); + } else if (a.account.data[0] == VaultKey.VaultV1) { + const vault = await decodeVault(a.account.data); + const account: ParsedAccount = { + pubkey: a.pubkey, + account: a.account, + info: vault, + }; + setVaults(e => ({ + ...e, + [a.pubkey.toBase58()]: account, + })); + } + } catch { + // ignore errors + // add type as first byte for easier deserialization + } + }; + + const accounts = await connection.getProgramAccounts(programIds().vault); + for (let i = 0; i < accounts.length; i++) { + await processVaultData(accounts[i]); + } + + let subId = connection.onProgramAccountChange( + programIds().vault, + async info => { + const pubkey = + typeof info.accountId === 'string' + ? new PublicKey((info.accountId as unknown) as string) + : info.accountId; + await processVaultData({ + pubkey, + account: info.accountInfo, + }); + }, + ); + dispose = () => { + connection.removeProgramAccountChangeListener(subId); + }; + })(); + + return () => { + dispose(); + }; + }, [connection, setSafetyDepositBoxesByVaultAndIndex, setVaults]); + + useEffect(() => { + let dispose = () => {}; + (async () => { + const processAuctionManagers = async (a: PublicKeyAndAccount) => { + try { + if (a.account.data[0] == MetaplexKey.AuctionManagerV1) { + const auctionManager = await decodeAuctionManager(a.account.data); + const account: ParsedAccount = { + pubkey: a.pubkey, + account: a.account, + info: auctionManager, + }; + setAuctionManagers(e => ({ + ...e, + [a.pubkey.toBase58()]: account, + })); + } else if (a.account.data[0] == MetaplexKey.BidRedemptionTicketV1) { + const ticket = await decodeBidRedemptionTicket(a.account.data); + const account: ParsedAccount = { + pubkey: a.pubkey, + account: a.account, + info: ticket, + }; + setBidRedemptions(e => ({ + ...e, + [a.pubkey.toBase58()]: account, + })); + } + } catch { + // ignore errors + // add type as first byte for easier deserialization + } + }; + + const accounts = await connection.getProgramAccounts( + programIds().metaplex, + ); + for (let i = 0; i < accounts.length; i++) { + await processAuctionManagers(accounts[i]); + } + + let subId = connection.onProgramAccountChange( + programIds().metaplex, + async info => { + const pubkey = + typeof info.accountId === 'string' + ? new PublicKey((info.accountId as unknown) as string) + : info.accountId; + await processAuctionManagers({ + pubkey, + account: info.accountInfo, + }); + }, + ); + dispose = () => { + connection.removeProgramAccountChangeListener(subId); + }; + })(); + + return () => { + dispose(); + }; + }, [connection, setAuctionManagers, setBidRedemptions]); + + useEffect(() => { + let dispose = () => {}; + (async () => { + const processMetaData = async (meta: PublicKeyAndAccount) => { + try { + if (meta.account.data[0] == MetadataKey.MetadataV1) { + const metadata = await decodeMetadata(meta.account.data); + + if ( + isValidHttpUrl(metadata.uri) && + metadata.uri.indexOf('arweave') >= 0 + ) { + const account: ParsedAccount = { + pubkey: meta.pubkey, + account: meta.account, + info: metadata, + }; + setMetadataByMint(e => ({ + ...e, + [metadata.mint.toBase58()]: account, + })); + } + } else if (meta.account.data[0] == MetadataKey.EditionV1) { + const edition = decodeEdition(meta.account.data); + const account: ParsedAccount = { + pubkey: meta.pubkey, + account: meta.account, + info: edition, + }; + setEditions(e => ({ ...e, [meta.pubkey.toBase58()]: account })); + } else if (meta.account.data[0] == MetadataKey.MasterEditionV1) { + const masterEdition = decodeMasterEdition(meta.account.data); + const account: ParsedAccount = { + pubkey: meta.pubkey, + account: meta.account, + info: masterEdition, + }; + setMasterEditions(e => ({ + ...e, + [meta.pubkey.toBase58()]: account, + })); + } else if (meta.account.data[0] == MetadataKey.NameSymbolTupleV1) { + const nameSymbolTuple = decodeNameSymbolTuple(meta.account.data); + const account: ParsedAccount = { + pubkey: meta.pubkey, + account: meta.account, + info: nameSymbolTuple, + }; + setNameSymbolTuples(e => ({ + ...e, + [meta.pubkey.toBase58()]: account, + })); + } + } catch { + // ignore errors + // add type as first byte for easier deserialization + } + }; + + const accounts = await connection.getProgramAccounts( + programIds().metadata, + ); + for (let i = 0; i < accounts.length; i++) { + await processMetaData(accounts[i]); + } + + setMetadataByMint(latest => { + queryExtendedMetadata( + connection, + setMetadata, + setMetadataByMint, + latest, + ); + return latest; + }); + + let subId = connection.onProgramAccountChange( + programIds().metadata, + async info => { + const pubkey = + typeof info.accountId === 'string' + ? new PublicKey((info.accountId as unknown) as string) + : info.accountId; + await processMetaData({ + pubkey, + account: info.accountInfo, + }); + setMetadataByMint(latest => { + queryExtendedMetadata( + connection, + setMetadata, + setMetadataByMint, + latest, + ); + return latest; + }); + }, + ); + dispose = () => { + connection.removeProgramAccountChangeListener(subId); + }; + })(); + + return () => { + dispose(); + }; + }, [ + connection, + setMetadata, + setMasterEditions, + setNameSymbolTuples, + setEditions, + ]); + + return ( + + {children} + + ); +} + +const queryExtendedMetadata = async ( + connection: Connection, + setMetadata: (metadata: ParsedAccount[]) => void, + setMetadataByMint: ( + metadata: Record>, + ) => void, + mintToMeta: Record>, +) => { + const mintToMetadata = { ...mintToMeta }; + const extendedMetadataFetch = new Map>(); + + const mints = await getMultipleAccounts( + connection, + [...Object.keys(mintToMetadata)].filter(k => !cache.get(k)), + 'single', + ); + mints.keys.forEach((key, index) => { + const mintAccount = mints.array[index]; + const mint = cache.add( + key, + mintAccount, + MintParser, + ) as ParsedAccount; + if (mint.info.supply.gt(new BN(1)) || mint.info.decimals !== 0) { + // naive not NFT check + delete mintToMetadata[key]; + } else { + const metadata = mintToMetadata[key]; + + + } + }); + + // await Promise.all([...extendedMetadataFetch.values()]); + + setMetadata([...Object.values(mintToMetadata)]); + setMetadataByMint(mintToMetadata); +}; + +export const useMeta = () => { + const context = useContext(MetaContext); + return context as MetaContextState; +}; + +function isValidHttpUrl(text: string) { + let url; + + try { + url = new URL(text); + } catch (_) { + return false; + } + + return url.protocol === 'http:' || url.protocol === 'https:'; +} diff --git a/packages/metavinci/src/hooks/index.ts b/packages/metavinci/src/hooks/index.ts new file mode 100644 index 0000000..738d173 --- /dev/null +++ b/packages/metavinci/src/hooks/index.ts @@ -0,0 +1,5 @@ +export * from './useArt'; +export * from './useAuctions'; +export * from './useUserArts'; +export * from './useAuction'; +export * from './useBidsForAuction'; diff --git a/packages/metavinci/src/hooks/useArt.ts b/packages/metavinci/src/hooks/useArt.ts new file mode 100644 index 0000000..cabe09c --- /dev/null +++ b/packages/metavinci/src/hooks/useArt.ts @@ -0,0 +1,65 @@ +import React, { useEffect, useMemo, useState } from 'react'; +import { PublicKey } from '@solana/web3.js'; +import { useMeta } from '../contexts'; +import { Art } from '../types'; +import { Metadata } from '@oyster/common'; + +export const metadataToArt = (info: Metadata | undefined) => { + return { + image: info?.extended?.image, + category: info?.extended?.category, + title: info?.name, + about: info?.extended?.description, + royalties: info?.extended?.royalty, + } as Art; +}; + +export const useArt = (id?: PublicKey | string) => { + const { metadata } = useMeta(); + + const key = typeof id === 'string' ? id : id?.toBase58() || ''; + const account = useMemo( + () => metadata.find(a => a.pubkey.toBase58() === key), + [key, metadata], + ); + + const [art, setArt] = useState(metadataToArt(account?.info)); + + useEffect(() => { + if (account && account.info.uri) { + fetch(account.info.uri, { cache: 'force-cache' }) + .then(async _ => { + try { + account.info.extended = await _.json(); + if ( + !account.info.extended || + account.info.extended?.files?.length === 0 + ) { + return; + } + + if (account.info.extended?.image) { + const file = `${account.info.uri}/${account.info.extended.image}`; + account.info.extended.image = file; + await fetch(file, { cache: 'force-cache' }) + .then(res => res.blob()) + .then( + blob => + account.info.extended && + (account.info.extended.image = URL.createObjectURL(blob)), + ); + + setArt(metadataToArt(account?.info)); + } + } catch { + return undefined; + } + }) + .catch(() => { + return undefined; + }); + } + }, [account, setArt, metadata]); + + return art; +}; diff --git a/packages/metavinci/src/hooks/useAuction.ts b/packages/metavinci/src/hooks/useAuction.ts new file mode 100644 index 0000000..22c5c4f --- /dev/null +++ b/packages/metavinci/src/hooks/useAuction.ts @@ -0,0 +1,64 @@ +import { TokenAccount, useConnection, useUserAccounts } from '@oyster/common'; +import { useEffect, useState } from 'react'; +import { AuctionView, processAccountsIntoAuctionView } from '.'; +import { useMeta } from '../contexts'; + +export const useAuction = (id: string) => { + const connection = useConnection(); + const { userAccounts } = useUserAccounts(); + const accountByMint = userAccounts.reduce((prev, acc) => { + prev.set(acc.info.mint.toBase58(), acc); + return prev; + }, new Map()); + const [existingAuctionView, setAuctionView] = useState( + null, + ); + + const { + auctions, + auctionManagers, + safetyDepositBoxesByVaultAndIndex, + metadataByMint, + bidderMetadataByAuctionAndBidder, + bidderPotsByAuctionAndBidder, + masterEditions, + nameSymbolTuples, + bidRedemptions, + vaults, + } = useMeta(); + + useEffect(() => { + const auction = auctions[id]; + if (auction) { + const auctionView = processAccountsIntoAuctionView( + auction, + auctionManagers, + safetyDepositBoxesByVaultAndIndex, + metadataByMint, + nameSymbolTuples, + bidRedemptions, + bidderMetadataByAuctionAndBidder, + bidderPotsByAuctionAndBidder, + masterEditions, + vaults, + accountByMint, + undefined, + existingAuctionView || undefined, + ); + if (auctionView) setAuctionView(auctionView); + } + }, [ + auctions, + auctionManagers, + safetyDepositBoxesByVaultAndIndex, + metadataByMint, + bidderMetadataByAuctionAndBidder, + bidderPotsByAuctionAndBidder, + vaults, + nameSymbolTuples, + masterEditions, + bidRedemptions, + userAccounts, + ]); + return existingAuctionView; +}; diff --git a/packages/metavinci/src/hooks/useAuctions.ts b/packages/metavinci/src/hooks/useAuctions.ts new file mode 100644 index 0000000..354aea1 --- /dev/null +++ b/packages/metavinci/src/hooks/useAuctions.ts @@ -0,0 +1,291 @@ +import { + ParsedAccount, + Metadata, + SafetyDepositBox, + AuctionData, + useConnection, + AuctionState, + BidderMetadata, + BidderPot, + useUserAccounts, + TokenAccount, + Vault, + MasterEdition, + NameSymbolTuple, +} from '@oyster/common'; +import { useEffect, useState } from 'react'; +import { useMeta } from '../contexts'; +import { AuctionManager, BidRedemptionTicket } from '../models/metaplex'; + +export enum AuctionViewState { + Live = '0', + Upcoming = '1', + Ended = '2', + BuyNow = '3', +} + +export interface AuctionViewItem { + metadata: ParsedAccount; + nameSymbol?: ParsedAccount; + safetyDeposit: ParsedAccount; + masterEdition?: ParsedAccount; +} + +// Flattened surface item for easy display +export interface AuctionView { + items: AuctionViewItem[]; + auction: ParsedAccount; + auctionManager: ParsedAccount; + openEditionItem?: AuctionViewItem; + state: AuctionViewState; + thumbnail: AuctionViewItem; + myBidderMetadata?: ParsedAccount; + myBidderPot?: ParsedAccount; + myBidRedemption?: ParsedAccount; + vault: ParsedAccount; + totallyComplete: boolean; +} + +export const useAuctions = (state: AuctionViewState) => { + const { userAccounts } = useUserAccounts(); + const accountByMint = userAccounts.reduce((prev, acc) => { + prev.set(acc.info.mint.toBase58(), acc); + return prev; + }, new Map()); + + const [auctionViews, setAuctionViews] = useState< + Record + >({}); + + const { + auctions, + auctionManagers, + safetyDepositBoxesByVaultAndIndex, + metadataByMint, + bidderMetadataByAuctionAndBidder, + bidderPotsByAuctionAndBidder, + vaults, + nameSymbolTuples, + masterEditions, + bidRedemptions, + } = useMeta(); + + useEffect(() => { + Object.keys(auctions).forEach(a => { + const auction = auctions[a]; + const existingAuctionView = auctionViews[a]; + const nextAuctionView = processAccountsIntoAuctionView( + auction, + auctionManagers, + safetyDepositBoxesByVaultAndIndex, + metadataByMint, + nameSymbolTuples, + bidRedemptions, + bidderMetadataByAuctionAndBidder, + bidderPotsByAuctionAndBidder, + masterEditions, + vaults, + accountByMint, + state, + existingAuctionView, + ); + setAuctionViews(nA => ({ ...nA, [a]: nextAuctionView })); + }); + }, [ + state, + auctions, + auctionManagers, + safetyDepositBoxesByVaultAndIndex, + metadataByMint, + bidderMetadataByAuctionAndBidder, + bidderPotsByAuctionAndBidder, + userAccounts, + vaults, + nameSymbolTuples, + masterEditions, + bidRedemptions, + ]); + + return Object.values(auctionViews).filter(v => v) as AuctionView[]; +}; + +export function processAccountsIntoAuctionView( + auction: ParsedAccount, + auctionManagers: Record>, + safetyDepositBoxesByVaultAndIndex: Record< + string, + ParsedAccount + >, + metadataByMint: Record>, + nameSymbolTuples: Record>, + bidRedemptions: Record>, + bidderMetadataByAuctionAndBidder: Record< + string, + ParsedAccount + >, + bidderPotsByAuctionAndBidder: Record>, + masterEditions: Record>, + vaults: Record>, + accountByMint: Map, + desiredState: AuctionViewState | undefined, + existingAuctionView?: AuctionView, +): AuctionView | undefined { + let state: AuctionViewState; + if (auction.info.state == AuctionState.Ended) { + state = AuctionViewState.Ended; + } else if (auction.info.state == AuctionState.Started) { + state = AuctionViewState.Live; + } else if (auction.info.state == AuctionState.Created) { + state = AuctionViewState.Upcoming; + } else { + state = AuctionViewState.BuyNow; + } + + if (desiredState && desiredState != state) return undefined; + + const myPayingAccount = accountByMint.get(auction.info.tokenMint.toBase58()); + + const auctionManager = + auctionManagers[auction.info.auctionManagerKey?.toBase58() || '']; + if (auctionManager) { + const boxesExpected = auctionManager.info.state.winningConfigsValidated; + + let bidRedemption: + | ParsedAccount + | undefined = undefined; + if (auction.info.bidRedemptionKey?.toBase58()) { + bidRedemption = bidRedemptions[auction.info.bidRedemptionKey?.toBase58()]; + } + + const bidderMetadata = + bidderMetadataByAuctionAndBidder[ + auction.pubkey.toBase58() + '-' + myPayingAccount?.pubkey.toBase58() + ]; + const bidderPot = + bidderPotsByAuctionAndBidder[ + auction.pubkey.toBase58() + '-' + myPayingAccount?.pubkey.toBase58() + ]; + + if (existingAuctionView && existingAuctionView.totallyComplete) { + // If totally complete, we know we arent updating anythign else, let's speed things up + // and only update the two things that could possibly change + existingAuctionView.myBidderPot = bidderPot; + existingAuctionView.myBidderMetadata = bidderMetadata; + existingAuctionView.myBidRedemption = bidRedemption; + for (let i = 0; i < existingAuctionView.items.length; i++) { + let curr = existingAuctionView.items[i]; + if (!curr.metadata) { + let foundMetadata = + metadataByMint[curr.safetyDeposit.info.tokenMint.toBase58()]; + curr.metadata = foundMetadata; + } + if ( + curr.metadata && + !curr.nameSymbol && + curr.metadata.info.nameSymbolTuple + ) { + let foundNS = + nameSymbolTuples[curr.metadata.info.nameSymbolTuple.toBase58()]; + curr.nameSymbol = foundNS; + } + + if ( + curr.metadata && + !curr.masterEdition && + curr.metadata.info.masterEdition + ) { + let foundMaster = + masterEditions[curr.metadata.info.masterEdition.toBase58()]; + + curr.masterEdition = foundMaster; + } + } + + return existingAuctionView; + } + + let boxes: ParsedAccount[] = []; + + let box = + safetyDepositBoxesByVaultAndIndex[ + auctionManager.info.vault.toBase58() + '-0' + ]; + if (box) { + boxes.push(box); + let i = 1; + while (box) { + box = + safetyDepositBoxesByVaultAndIndex[ + auctionManager.info.vault.toBase58() + '-' + i.toString() + ]; + if (box) boxes.push(box); + i++; + } + } + + if (boxes.length > 0) { + let view: Partial = { + auction, + auctionManager, + state, + vault: vaults[auctionManager.info.vault.toBase58()], + items: auctionManager.info.settings.winningConfigs.map(w => { + let metadata = + metadataByMint[ + boxes[w.safetyDepositBoxIndex].info.tokenMint.toBase58() + ]; + return { + metadata, + nameSymbol: metadata?.info?.nameSymbolTuple + ? nameSymbolTuples[metadata.info.nameSymbolTuple.toBase58()] + : undefined, + safetyDeposit: boxes[w.safetyDepositBoxIndex], + masterEdition: metadata?.info?.masterEdition + ? masterEditions[metadata.info.masterEdition.toBase58()] + : undefined, + }; + }), + openEditionItem: + auctionManager.info.settings.openEditionConfig != null + ? { + metadata: + metadataByMint[ + boxes[ + auctionManager.info.settings.openEditionConfig + ].info.tokenMint.toBase58() + ], + safetyDeposit: + boxes[auctionManager.info.settings.openEditionConfig], + masterEdition: + masterEditions[ + metadataByMint[ + boxes[ + auctionManager.info.settings.openEditionConfig + ].info.tokenMint.toBase58() + ]?.info.masterEdition?.toBase58() || '' + ], + } + : undefined, + myBidderMetadata: bidderMetadata, + myBidderPot: bidderPot, + myBidRedemption: bidRedemption, + }; + + view.thumbnail = (view.items || [])[0] || view.openEditionItem; + view.totallyComplete = !!( + view.thumbnail && + boxesExpected == + (view.items || []).length + + (auctionManager.info.settings.openEditionConfig == null ? 0 : 1) && + (auctionManager.info.settings.openEditionConfig == null || + (auctionManager.info.settings.openEditionConfig != null && + view.openEditionItem)) && + view.vault + ); + if (!view.thumbnail || !view.thumbnail.metadata) return undefined; + return view as AuctionView; + } + } + + return undefined; +} diff --git a/packages/metavinci/src/hooks/useBidsForAuction.ts b/packages/metavinci/src/hooks/useBidsForAuction.ts new file mode 100644 index 0000000..f290023 --- /dev/null +++ b/packages/metavinci/src/hooks/useBidsForAuction.ts @@ -0,0 +1,44 @@ +import React, { useMemo } from 'react'; +import { PublicKey } from '@solana/web3.js'; +import { + AuctionData, + BidderMetadata, + BidderMetadataParser, + cache, + ParsedAccount, +} from '@oyster/common'; + +export const useBidsForAuction = (auctionPubkey: PublicKey | string) => { + const id = useMemo( + () => + typeof auctionPubkey === 'string' + ? auctionPubkey + : auctionPubkey.toBase58(), + [auctionPubkey], + ); + + const auction = cache.get(auctionPubkey) as ParsedAccount; + + const bids = cache + .byParser(BidderMetadataParser) + .filter(key => { + const bidder = cache.get(key) as ParsedAccount; + if (!bidder) { + return false; + } + + return bidder.info.auctionPubkey.toBase58() === id; + }) + .map(key => { + const bidder = cache.get(key) as ParsedAccount; + return bidder; + }) + .sort((a, b) => a.info.lastBid.sub(a.info.lastBid).toNumber()) + .map(item => { + return { + ...item, + }; + }); + + return bids; +}; diff --git a/packages/metavinci/src/hooks/useUserArts.ts b/packages/metavinci/src/hooks/useUserArts.ts new file mode 100644 index 0000000..5c06c8c --- /dev/null +++ b/packages/metavinci/src/hooks/useUserArts.ts @@ -0,0 +1,54 @@ +import { TokenAccount, useUserAccounts } from '@oyster/common'; +import { SafetyDepositDraft } from '../actions/createAuctionManager'; +import { useMeta } from './../contexts'; + +export const useUserArts = (): SafetyDepositDraft[] => { + const { metadata, masterEditions, editions, nameSymbolTuples } = useMeta(); + const { userAccounts } = useUserAccounts(); + const accountByMint = userAccounts.reduce((prev, acc) => { + prev.set(acc.info.mint.toBase58(), acc); + return prev; + }, new Map()); + + const ownedMetadata = metadata.filter( + m => + accountByMint.has(m.info.mint.toBase58()) && + (accountByMint?.get(m.info.mint.toBase58())?.info?.amount?.toNumber() || + 0) > 0, + ); + + const possibleNameSymbols = ownedMetadata.map(m => + m.info.nameSymbolTuple + ? nameSymbolTuples[m.info.nameSymbolTuple?.toBase58()] + : undefined, + ); + + const possibleEditions = ownedMetadata.map(m => + m.info.edition ? editions[m.info.edition?.toBase58()] : undefined, + ); + + const possibleMasterEditions = ownedMetadata.map(m => + m.info.masterEdition + ? masterEditions[m.info.masterEdition?.toBase58()] + : undefined, + ); + + let safetyDeposits: SafetyDepositDraft[] = []; + let i = 0; + ownedMetadata.forEach(m => { + let a = accountByMint.get(m.info.mint.toBase58()); + + if (a) { + safetyDeposits.push({ + holding: a.pubkey, + nameSymbol: possibleNameSymbols[i], + edition: possibleEditions[i], + masterEdition: possibleMasterEditions[i], + metadata: m, + }); + } + i++; + }); + + return safetyDeposits; +}; diff --git a/packages/metavinci/src/index.tsx b/packages/metavinci/src/index.tsx new file mode 100644 index 0000000..d8901bc --- /dev/null +++ b/packages/metavinci/src/index.tsx @@ -0,0 +1,17 @@ +import './wdyr'; + +import React from 'react'; +import ReactDOM from 'react-dom'; +import App from './App'; +import * as serviceWorker from './serviceWorker'; +ReactDOM.render( + + + , + document.getElementById('root'), +); + +// If you want your app to work offline and load faster, you can change +// unregister() to register() below. Note this comes with some pitfalls. +// Learn more about service workers: https://bit.ly/CRA-PWA +serviceWorker.unregister(); diff --git a/packages/metavinci/src/manifest.json b/packages/metavinci/src/manifest.json new file mode 100644 index 0000000..64189b0 --- /dev/null +++ b/packages/metavinci/src/manifest.json @@ -0,0 +1,22 @@ +{ + "name": "Metaplex NFT Marketplace", + "short_name": "Metaplex NFT Marketplace", + "display": "standalone", + "start_url": "./", + "theme_color": "#002140", + "background_color": "#001529", + "icons": [ + { + "src": "icons/icon-192x192.png", + "sizes": "192x192" + }, + { + "src": "icons/icon-128x128.png", + "sizes": "128x128" + }, + { + "src": "icons/icon-512x512.png", + "sizes": "512x512" + } + ] +} diff --git a/packages/metavinci/src/models/dex/index.ts b/packages/metavinci/src/models/dex/index.ts new file mode 100644 index 0000000..9fc9e36 --- /dev/null +++ b/packages/metavinci/src/models/dex/index.ts @@ -0,0 +1 @@ +export * from './market'; diff --git a/packages/metavinci/src/models/dex/market.ts b/packages/metavinci/src/models/dex/market.ts new file mode 100644 index 0000000..54aee09 --- /dev/null +++ b/packages/metavinci/src/models/dex/market.ts @@ -0,0 +1,47 @@ +import { contexts, ParsedAccountBase } from '@oyster/common'; +import { Market, MARKETS, Orderbook } from '@project-serum/serum'; +import { AccountInfo, PublicKey } from '@solana/web3.js'; +const { MintParser, cache } = contexts.Accounts; + +export const OrderBookParser = (id: PublicKey, acc: AccountInfo) => { + const decoded = Orderbook.LAYOUT.decode(acc.data); + + const details = { + pubkey: id, + account: { + ...acc, + }, + info: decoded, + } as ParsedAccountBase; + + return details; +}; + +const DEFAULT_DEX_ID = new PublicKey( + 'EUqojwWA2rd19FZrzeBncJsm38Jm1hEhE3zsmX3bRc2o', +); + +export const DexMarketParser = ( + pubkey: PublicKey, + acc: AccountInfo, +) => { + const market = MARKETS.find(m => m.address.equals(pubkey)); + const decoded = Market.getLayout(market?.programId || DEFAULT_DEX_ID).decode( + acc.data, + ); + + const details = { + pubkey, + account: { + ...acc, + }, + info: decoded, + } as ParsedAccountBase; + + cache.registerParser(details.info.baseMint, MintParser); + cache.registerParser(details.info.quoteMint, MintParser); + cache.registerParser(details.info.bids, OrderBookParser); + cache.registerParser(details.info.asks, OrderBookParser); + + return details; +}; diff --git a/packages/metavinci/src/models/index.ts b/packages/metavinci/src/models/index.ts new file mode 100644 index 0000000..ef81038 --- /dev/null +++ b/packages/metavinci/src/models/index.ts @@ -0,0 +1 @@ +export * from './dex'; diff --git a/packages/metavinci/src/models/marketOverrides.ts b/packages/metavinci/src/models/marketOverrides.ts new file mode 100644 index 0000000..1a626c8 --- /dev/null +++ b/packages/metavinci/src/models/marketOverrides.ts @@ -0,0 +1,2 @@ +// use to override serum market to use specifc mint +export const MINT_TO_MARKET: { [key: string]: string } = {}; diff --git a/packages/metavinci/src/models/metaplex/index.ts b/packages/metavinci/src/models/metaplex/index.ts new file mode 100644 index 0000000..c4f36a6 --- /dev/null +++ b/packages/metavinci/src/models/metaplex/index.ts @@ -0,0 +1,411 @@ +import { + AUCTION_PREFIX, + deserializeBorsh, + programIds, + METADATA, + METADATA_PREFIX, + EDITION, +} from '@oyster/common'; +import { PublicKey } from '@solana/web3.js'; +import BN from 'bn.js'; +import { serialize, BinaryReader, BinaryWriter } from 'borsh'; + +export * from './initAuctionManager'; +export * from './redeemBid'; +export * from './redeemLimitedEditionBid'; +export * from './redeemMasterEditionBid'; +export * from './redeemOpenEditionBid'; +export * from './startAuction'; +export * from './validateSafetyDepositBox'; + +export const METAPLEX_PREFIX = 'metaplex'; +export const ORIGINAL_AUTHORITY_LOOKUP_SIZE = 33; + +export enum MetaplexKey { + AuctionManagerV1 = 0, + OriginalAuthorityLookupV1 = 1, + BidRedemptionTicketV1 = 2, +} +export class AuctionManager { + key: MetaplexKey; + authority: PublicKey; + auction: PublicKey; + vault: PublicKey; + auctionProgram: PublicKey; + tokenVaultProgram: PublicKey; + tokenMetadataProgram: PublicKey; + tokenProgram: PublicKey; + acceptPayment: PublicKey; + state: AuctionManagerState; + settings: AuctionManagerSettings; + + constructor(args: { + authority: PublicKey; + auction: PublicKey; + vault: PublicKey; + auctionProgram: PublicKey; + tokenVaultProgram: PublicKey; + tokenMetadataProgram: PublicKey; + tokenProgram: PublicKey; + acceptPayment: PublicKey; + state: AuctionManagerState; + settings: AuctionManagerSettings; + }) { + this.key = MetaplexKey.AuctionManagerV1; + this.authority = args.authority; + this.auction = args.auction; + this.vault = args.vault; + this.auctionProgram = args.auctionProgram; + this.tokenVaultProgram = args.tokenVaultProgram; + this.tokenMetadataProgram = args.tokenMetadataProgram; + this.tokenProgram = args.tokenProgram; + this.acceptPayment = args.acceptPayment; + this.state = args.state; + this.settings = args.settings; + } +} + +export class InitAuctionManagerArgs { + instruction = 0; + settings: AuctionManagerSettings; + + constructor(args: { settings: AuctionManagerSettings }) { + this.settings = args.settings; + } +} + +export class ValidateSafetyDepositBoxArgs { + instruction = 1; +} + +export class RedeemBidArgs { + instruction = 2; +} + +export class RedeemMasterEditionBidArgs { + instruction = 3; +} + +export class RedeemLimitedEditionBidArgs { + instruction = 4; +} + +export class RedeemOpenEditionBidArgs { + instruction = 5; +} + +export class StartAuctionArgs { + instruction = 6; +} + +export class AuctionManagerSettings { + openEditionWinnerConstraint: WinningConstraint = + WinningConstraint.NoOpenEdition; + openEditionNonWinningConstraint: NonWinningConstraint = + NonWinningConstraint.GivenForFixedPrice; + winningConfigs: WinningConfig[] = []; + openEditionConfig: number | null = 0; + openEditionFixedPrice: BN | null = new BN(0); + + constructor(args?: AuctionManagerSettings) { + Object.assign(this, args); + } +} + +export enum WinningConstraint { + NoOpenEdition = 0, + OpenEditionGiven = 1, +} + +export enum NonWinningConstraint { + NoOpenEdition = 0, + GivenForFixedPrice = 1, + GivenForBidPrice = 2, +} + +export enum EditionType { + // Not an edition + NA, + /// Means you are auctioning off the master edition record + MasterEdition, + /// Means you are using the master edition to print off new editions during the auction (limited or open edition) + LimitedEdition, +} + +export class WinningConfig { + safetyDepositBoxIndex: number = 0; + amount: number = 0; + editionType: EditionType = EditionType.NA; + + constructor(args?: WinningConfig) { + Object.assign(this, args); + } +} +export const decodeAuctionManager = (buffer: Buffer) => { + return deserializeBorsh(SCHEMA, AuctionManager, buffer) as AuctionManager; +}; + +export const decodeBidRedemptionTicket = (buffer: Buffer) => { + return deserializeBorsh( + SCHEMA, + BidRedemptionTicket, + buffer, + ) as BidRedemptionTicket; +}; + +export class WinningConfigState { + amountMinted: number = 0; + validated: boolean = false; + claimed: boolean = false; + + constructor(args?: WinningConfigState) { + Object.assign(this, args); + } +} + +export class AuctionManagerState { + status: AuctionManagerStatus = AuctionManagerStatus.Initialized; + winningConfigsValidated: number = 0; + masterEditionsWithAuthoritiesRemainingToReturn: number = 0; + + winningConfigStates: WinningConfigState[] = []; + + constructor(args?: AuctionManagerState) { + Object.assign(this, args); + } +} + +export enum AuctionManagerStatus { + Initialized, + Validated, + Running, + Disbursing, + Finished, +} + +export class BidRedemptionTicket { + key: MetaplexKey = MetaplexKey.BidRedemptionTicketV1; + openEditionRedeemed: boolean = false; + bidRedeemed: boolean = false; + + constructor(args?: BidRedemptionTicket) { + Object.assign(this, args); + } +} + +export const SCHEMA = new Map([ + [ + AuctionManager, + { + kind: 'struct', + fields: [ + ['key', 'u8'], + ['authority', 'pubkey'], + ['auction', 'pubkey'], + ['vault', 'pubkey'], + ['auctionProgram', 'pubkey'], + ['tokenVaultProgram', 'pubkey'], + ['tokenMetadataProgram', 'pubkey'], + ['tokenProgram', 'pubkey'], + ['acceptPayment', 'pubkey'], + ['state', AuctionManagerState], + ['settings', AuctionManagerSettings], + ], + }, + ], + [ + AuctionManagerSettings, + { + kind: 'struct', + fields: [ + ['openEditionWinnerConstraint', 'u8'], // enum + ['openEditionNonWinningConstraint', 'u8'], + ['winningConfigs', [WinningConfig]], + ['openEditionConfig', { kind: 'option', type: 'u8' }], + ['openEditionFixedPrice', { kind: 'option', type: 'u64' }], + ], + }, + ], + [ + WinningConfig, + { + kind: 'struct', + fields: [ + ['safetyDepositBoxIndex', 'u8'], + ['amount', 'u8'], + ['editionType', 'u8'], + ], + }, + ], + [ + WinningConfigState, + { + kind: 'struct', + fields: [ + ['amountMinted', 'u8'], + ['validated', 'u8'], // bool + ['claimed', 'u8'], // bool + ], + }, + ], + [ + AuctionManagerState, + { + kind: 'struct', + fields: [ + ['status', 'u8'], + ['winningConfigsValidated', 'u8'], + ['masterEditionsWithAuthoritiesRemainingToReturn', 'u8'], + ['winningConfigStates', [WinningConfigState]], + ], + }, + ], + [ + BidRedemptionTicket, + { + kind: 'struct', + fields: [ + ['openEditionRedeemed', 'u8'], // bool + ['bidRedeemed', 'u8'], // bool + ], + }, + ], + [ + InitAuctionManagerArgs, + { + kind: 'struct', + fields: [ + ['instruction', 'u8'], + ['settings', AuctionManagerSettings], + ], + }, + ], + [ + ValidateSafetyDepositBoxArgs, + { + kind: 'struct', + fields: [['instruction', 'u8']], + }, + ], + [ + RedeemBidArgs, + { + kind: 'struct', + fields: [['instruction', 'u8']], + }, + ], + [ + RedeemMasterEditionBidArgs, + { + kind: 'struct', + fields: [['instruction', 'u8']], + }, + ], + [ + RedeemLimitedEditionBidArgs, + { + kind: 'struct', + fields: [['instruction', 'u8']], + }, + ], + [ + RedeemOpenEditionBidArgs, + { + kind: 'struct', + fields: [['instruction', 'u8']], + }, + ], + [ + StartAuctionArgs, + { + kind: 'struct', + fields: [['instruction', 'u8']], + }, + ], +]); + +export async function getAuctionManagerKey( + vault: PublicKey, + auctionKey: PublicKey, +): Promise { + const PROGRAM_IDS = programIds(); + + return ( + await PublicKey.findProgramAddress( + [Buffer.from(METAPLEX_PREFIX), auctionKey.toBuffer()], + PROGRAM_IDS.metaplex, + ) + )[0]; +} + +export async function getAuctionKeys( + vault: PublicKey, +): Promise<{ auctionKey: PublicKey; auctionManagerKey: PublicKey }> { + const PROGRAM_IDS = programIds(); + + const auctionKey: PublicKey = ( + await PublicKey.findProgramAddress( + [ + Buffer.from(AUCTION_PREFIX), + PROGRAM_IDS.auction.toBuffer(), + vault.toBuffer(), + ], + PROGRAM_IDS.auction, + ) + )[0]; + + const auctionManagerKey = await getAuctionManagerKey(vault, auctionKey); + + return { auctionKey, auctionManagerKey }; +} + +export async function getBidderKeys( + auctionKey: PublicKey, + bidder: PublicKey, +): Promise<{ bidMetadata: PublicKey; bidRedemption: PublicKey }> { + const PROGRAM_IDS = programIds(); + + const bidMetadata: PublicKey = ( + await PublicKey.findProgramAddress( + [ + Buffer.from(AUCTION_PREFIX), + PROGRAM_IDS.auction.toBuffer(), + auctionKey.toBuffer(), + bidder.toBuffer(), + Buffer.from(METADATA), + ], + PROGRAM_IDS.auction, + ) + )[0]; + + const bidRedemption: PublicKey = ( + await PublicKey.findProgramAddress( + [ + Buffer.from(METAPLEX_PREFIX), + auctionKey.toBuffer(), + bidMetadata.toBuffer(), + ], + PROGRAM_IDS.metaplex, + ) + )[0]; + + return { bidMetadata, bidRedemption }; +} + +export async function getOriginalAuthority( + auctionKey: PublicKey, + metadata: PublicKey, +): Promise { + const PROGRAM_IDS = programIds(); + + return ( + await PublicKey.findProgramAddress( + [ + Buffer.from(METAPLEX_PREFIX), + auctionKey.toBuffer(), + metadata.toBuffer(), + ], + PROGRAM_IDS.metaplex, + ) + )[0]; +} diff --git a/packages/metavinci/src/models/metaplex/initAuctionManager.ts b/packages/metavinci/src/models/metaplex/initAuctionManager.ts new file mode 100644 index 0000000..9194c31 --- /dev/null +++ b/packages/metavinci/src/models/metaplex/initAuctionManager.ts @@ -0,0 +1,146 @@ +import { programIds } from '@oyster/common'; +import { + PublicKey, + SystemProgram, + SYSVAR_RENT_PUBKEY, + TransactionInstruction, +} from '@solana/web3.js'; +import { serialize } from 'borsh'; + +import { + AuctionManagerSettings, + getAuctionKeys, + InitAuctionManagerArgs, + SCHEMA, +} from '.'; + +export async function initAuctionManager( + vault: PublicKey, + openEditionMetadata: PublicKey | undefined, + openEditionNameSymbol: PublicKey | undefined, + openEditionAuthority: PublicKey | undefined, + openEditionMasterAccount: PublicKey | undefined, + openEditionMint: PublicKey | undefined, + openEditionMasterMint: PublicKey | undefined, + openEditionMasterMintAuthority: PublicKey | undefined, + auctionManagerAuthority: PublicKey, + payer: PublicKey, + acceptPaymentAccount: PublicKey, + settings: AuctionManagerSettings, + instructions: TransactionInstruction[], +) { + const PROGRAM_IDS = programIds(); + const { auctionKey, auctionManagerKey } = await getAuctionKeys(vault); + + const value = new InitAuctionManagerArgs({ + settings, + }); + + const data = Buffer.from(serialize(SCHEMA, value)); + console.log('mData', data, settings); + const keys = [ + { + pubkey: auctionManagerKey, + isSigner: false, + isWritable: true, + }, + { + pubkey: vault, + isSigner: false, + isWritable: false, + }, + + { + pubkey: auctionKey, + isSigner: false, + isWritable: false, + }, + { + pubkey: openEditionMetadata || SystemProgram.programId, // Won't actually be used if openEditionConfig is null + isSigner: false, + isWritable: true, + }, + { + pubkey: openEditionNameSymbol || SystemProgram.programId, // Won't actually be used if openEditionConfig is null + isSigner: false, + isWritable: true, + }, + { + pubkey: openEditionAuthority || SystemProgram.programId, // Won't actually be used if openEditionConfig is null + isSigner: true, + isWritable: false, + }, + { + pubkey: openEditionMasterAccount || SystemProgram.programId, // Won't actually be used if openEditionConfig is null + isSigner: false, + isWritable: false, + }, + { + pubkey: openEditionMint || SystemProgram.programId, // Won't actually be used if openEditionConfig is null + isSigner: false, + isWritable: true, + }, + { + pubkey: openEditionMasterMint || SystemProgram.programId, // Won't actually be used if openEditionConfig is null + isSigner: false, + isWritable: true, + }, + { + pubkey: openEditionMasterMintAuthority || SystemProgram.programId, // Won't actually be used if openEditionConfig is null + isSigner: true, + isWritable: false, + }, + { + pubkey: auctionManagerAuthority, + isSigner: false, + isWritable: false, + }, + { + pubkey: payer, + isSigner: true, + isWritable: false, + }, + { + pubkey: acceptPaymentAccount, + isSigner: false, + isWritable: false, + }, + { + pubkey: PROGRAM_IDS.token, + isSigner: false, + isWritable: false, + }, + { + pubkey: PROGRAM_IDS.vault, + isSigner: false, + isWritable: false, + }, + { + pubkey: PROGRAM_IDS.metadata, + isSigner: false, + isWritable: false, + }, + { + pubkey: PROGRAM_IDS.auction, + isSigner: false, + isWritable: false, + }, + { + pubkey: SystemProgram.programId, + isSigner: false, + isWritable: false, + }, + { + pubkey: SYSVAR_RENT_PUBKEY, + isSigner: false, + isWritable: false, + }, + ]; + instructions.push( + new TransactionInstruction({ + keys, + programId: PROGRAM_IDS.metaplex, + data, + }), + ); +} diff --git a/packages/metavinci/src/models/metaplex/redeemBid.ts b/packages/metavinci/src/models/metaplex/redeemBid.ts new file mode 100644 index 0000000..c8b49e8 --- /dev/null +++ b/packages/metavinci/src/models/metaplex/redeemBid.ts @@ -0,0 +1,141 @@ +import { programIds, VAULT_PREFIX } from '@oyster/common'; +import { + PublicKey, + SystemProgram, + SYSVAR_CLOCK_PUBKEY, + SYSVAR_RENT_PUBKEY, + TransactionInstruction, +} from '@solana/web3.js'; +import { serialize } from 'borsh'; + +import { getAuctionKeys, getBidderKeys, RedeemBidArgs, SCHEMA } from '.'; + +export async function redeemBid( + vault: PublicKey, + store: PublicKey, + destination: PublicKey, + safetyDeposit: PublicKey, + fractionMint: PublicKey, + bidder: PublicKey, + payer: PublicKey, + instructions: TransactionInstruction[], +) { + const PROGRAM_IDS = programIds(); + + const { auctionKey, auctionManagerKey } = await getAuctionKeys(vault); + + const { bidRedemption, bidMetadata } = await getBidderKeys( + auctionKey, + bidder, + ); + + const transferAuthority: PublicKey = ( + await PublicKey.findProgramAddress( + [Buffer.from(VAULT_PREFIX), PROGRAM_IDS.vault.toBuffer()], + PROGRAM_IDS.vault, + ) + )[0]; + + const value = new RedeemBidArgs(); + const data = Buffer.from(serialize(SCHEMA, value)); + const keys = [ + { + pubkey: auctionManagerKey, + isSigner: false, + isWritable: true, + }, + { + pubkey: store, + isSigner: false, + isWritable: true, + }, + { + pubkey: destination, + isSigner: false, + isWritable: true, + }, + { + pubkey: bidRedemption, + isSigner: false, + isWritable: true, + }, + { + pubkey: safetyDeposit, + isSigner: false, + isWritable: true, + }, + { + pubkey: vault, + isSigner: false, + isWritable: true, + }, + { + pubkey: fractionMint, + isSigner: false, + isWritable: true, + }, + { + pubkey: auctionKey, + isSigner: false, + isWritable: false, + }, + { + pubkey: bidMetadata, + isSigner: false, + isWritable: false, + }, + { + pubkey: bidder, + isSigner: false, + isWritable: false, + }, + { + pubkey: payer, + isSigner: true, + isWritable: false, + }, + { + pubkey: PROGRAM_IDS.token, + isSigner: false, + isWritable: false, + }, + { + pubkey: PROGRAM_IDS.vault, + isSigner: false, + isWritable: false, + }, + { + pubkey: PROGRAM_IDS.metadata, + isSigner: false, + isWritable: false, + }, + { + pubkey: SystemProgram.programId, + isSigner: false, + isWritable: false, + }, + { + pubkey: SYSVAR_RENT_PUBKEY, + isSigner: false, + isWritable: false, + }, + { + pubkey: SYSVAR_CLOCK_PUBKEY, + isSigner: false, + isWritable: false, + }, + { + pubkey: transferAuthority, + isSigner: false, + isWritable: false, + }, + ]; + + instructions.push( + new TransactionInstruction({ + keys, + programId: PROGRAM_IDS.metaplex, + data, + }), + ); +} diff --git a/packages/metavinci/src/models/metaplex/redeemLimitedEditionBid.ts b/packages/metavinci/src/models/metaplex/redeemLimitedEditionBid.ts new file mode 100644 index 0000000..fc4d915 --- /dev/null +++ b/packages/metavinci/src/models/metaplex/redeemLimitedEditionBid.ts @@ -0,0 +1,174 @@ +import { getEdition, programIds, getMetadata } from '@oyster/common'; +import { + PublicKey, + SystemProgram, + SYSVAR_CLOCK_PUBKEY, + SYSVAR_RENT_PUBKEY, + TransactionInstruction, +} from '@solana/web3.js'; +import { serialize } from 'borsh'; + +import { + getAuctionKeys, + getBidderKeys, + getOriginalAuthority, + RedeemLimitedEditionBidArgs, + SCHEMA, +} from '.'; + +export async function redeemLimitedEditionBid( + vault: PublicKey, + store: PublicKey, + destination: PublicKey, + safetyDeposit: PublicKey, + fractionMint: PublicKey, + bidder: PublicKey, + payer: PublicKey, + instructions: TransactionInstruction[], + // as in original authority on the master metadata before it was shifted to auction manager, check + // originalAuthorityLookupKey's record for this value or just "know it" because it might be elsewhere. + originalAuthority: PublicKey, + tokenMint: PublicKey, + masterMint: PublicKey, +) { + const PROGRAM_IDS = programIds(); + + const { auctionKey, auctionManagerKey } = await getAuctionKeys(vault); + + const { bidRedemption, bidMetadata } = await getBidderKeys( + auctionKey, + bidder, + ); + + const masterMetadata: PublicKey = await getMetadata(tokenMint); + + const masterEdition: PublicKey = await getEdition(tokenMint); + + const originalAuthorityLookupKey: PublicKey = await getOriginalAuthority( + auctionKey, + masterMetadata, + ); + + const value = new RedeemLimitedEditionBidArgs(); + const data = Buffer.from(serialize(SCHEMA, value)); + const keys = [ + { + pubkey: auctionManagerKey, + isSigner: false, + isWritable: true, + }, + { + pubkey: store, + isSigner: false, + isWritable: true, + }, + { + pubkey: destination, + isSigner: false, + isWritable: true, + }, + { + pubkey: bidRedemption, + isSigner: false, + isWritable: true, + }, + { + pubkey: safetyDeposit, + isSigner: false, + isWritable: true, + }, + { + pubkey: vault, + isSigner: false, + isWritable: true, + }, + { + pubkey: fractionMint, + isSigner: false, + isWritable: true, + }, + { + pubkey: auctionKey, + isSigner: false, + isWritable: false, + }, + { + pubkey: bidMetadata, + isSigner: false, + isWritable: false, + }, + { + pubkey: bidder, + isSigner: false, + isWritable: false, + }, + { + pubkey: payer, + isSigner: true, + isWritable: false, + }, + { + pubkey: PROGRAM_IDS.token, + isSigner: false, + isWritable: false, + }, + { + pubkey: PROGRAM_IDS.vault, + isSigner: false, + isWritable: false, + }, + { + pubkey: PROGRAM_IDS.metadata, + isSigner: false, + isWritable: false, + }, + { + pubkey: SystemProgram.programId, + isSigner: false, + isWritable: false, + }, + { + pubkey: SYSVAR_RENT_PUBKEY, + isSigner: false, + isWritable: false, + }, + { + pubkey: SYSVAR_CLOCK_PUBKEY, + isSigner: false, + isWritable: false, + }, + { + pubkey: masterMetadata, + isSigner: false, + isWritable: false, + }, + { + pubkey: masterMint, + isSigner: false, + isWritable: true, + }, + { + pubkey: masterEdition, + isSigner: false, + isWritable: true, + }, + { + pubkey: originalAuthority, + isSigner: false, + isWritable: false, + }, + { + pubkey: originalAuthorityLookupKey, + isSigner: false, + isWritable: false, + }, + ]; + + instructions.push( + new TransactionInstruction({ + keys, + programId: PROGRAM_IDS.metaplex, + data, + }), + ); +} diff --git a/packages/metavinci/src/models/metaplex/redeemMasterEditionBid.ts b/packages/metavinci/src/models/metaplex/redeemMasterEditionBid.ts new file mode 100644 index 0000000..24bf9af --- /dev/null +++ b/packages/metavinci/src/models/metaplex/redeemMasterEditionBid.ts @@ -0,0 +1,164 @@ +import { programIds, VAULT_PREFIX, getMetadata } from '@oyster/common'; +import { + PublicKey, + SystemProgram, + SYSVAR_CLOCK_PUBKEY, + SYSVAR_RENT_PUBKEY, + TransactionInstruction, +} from '@solana/web3.js'; +import { serialize } from 'borsh'; + +import { + getAuctionKeys, + getBidderKeys, + RedeemMasterEditionBidArgs, + SCHEMA, +} from '.'; + +export async function redeemMasterEditionBid( + vault: PublicKey, + store: PublicKey, + destination: PublicKey, + safetyDeposit: PublicKey, + fractionMint: PublicKey, + bidder: PublicKey, + payer: PublicKey, + instructions: TransactionInstruction[], + masterMetadata: PublicKey, + masterNameSymbol: PublicKey | undefined, + newAuthority: PublicKey, +) { + const PROGRAM_IDS = programIds(); + + const { auctionKey, auctionManagerKey } = await getAuctionKeys(vault); + + const { bidRedemption, bidMetadata } = await getBidderKeys( + auctionKey, + bidder, + ); + + const transferAuthority: PublicKey = ( + await PublicKey.findProgramAddress( + [Buffer.from(VAULT_PREFIX), PROGRAM_IDS.vault.toBuffer()], + PROGRAM_IDS.vault, + ) + )[0]; + + const value = new RedeemMasterEditionBidArgs(); + const data = Buffer.from(serialize(SCHEMA, value)); + const keys = [ + { + pubkey: auctionManagerKey, + isSigner: false, + isWritable: true, + }, + { + pubkey: store, + isSigner: false, + isWritable: true, + }, + { + pubkey: destination, + isSigner: false, + isWritable: true, + }, + { + pubkey: bidRedemption, + isSigner: false, + isWritable: true, + }, + { + pubkey: safetyDeposit, + isSigner: false, + isWritable: true, + }, + { + pubkey: vault, + isSigner: false, + isWritable: true, + }, + { + pubkey: fractionMint, + isSigner: false, + isWritable: true, + }, + { + pubkey: auctionKey, + isSigner: false, + isWritable: false, + }, + { + pubkey: bidMetadata, + isSigner: false, + isWritable: false, + }, + { + pubkey: bidder, + isSigner: false, + isWritable: false, + }, + { + pubkey: payer, + isSigner: true, + isWritable: false, + }, + { + pubkey: PROGRAM_IDS.token, + isSigner: false, + isWritable: false, + }, + { + pubkey: PROGRAM_IDS.vault, + isSigner: false, + isWritable: false, + }, + { + pubkey: PROGRAM_IDS.metadata, + isSigner: false, + isWritable: false, + }, + { + pubkey: SystemProgram.programId, + isSigner: false, + isWritable: false, + }, + { + pubkey: SYSVAR_RENT_PUBKEY, + isSigner: false, + isWritable: false, + }, + { + pubkey: SYSVAR_CLOCK_PUBKEY, + isSigner: false, + isWritable: false, + }, + { + pubkey: masterMetadata, + isSigner: false, + isWritable: true, + }, + { + pubkey: masterNameSymbol || SystemProgram.programId, + isSigner: false, + isWritable: true, + }, + { + pubkey: newAuthority, + isSigner: false, + isWritable: false, + }, + { + pubkey: transferAuthority, + isSigner: false, + isWritable: false, + }, + ]; + + instructions.push( + new TransactionInstruction({ + keys, + programId: PROGRAM_IDS.metaplex, + data, + }), + ); +} diff --git a/packages/metavinci/src/models/metaplex/redeemOpenEditionBid.ts b/packages/metavinci/src/models/metaplex/redeemOpenEditionBid.ts new file mode 100644 index 0000000..5a7018f --- /dev/null +++ b/packages/metavinci/src/models/metaplex/redeemOpenEditionBid.ts @@ -0,0 +1,166 @@ +import { getEdition, programIds, getMetadata } from '@oyster/common'; +import { + PublicKey, + SystemProgram, + SYSVAR_CLOCK_PUBKEY, + SYSVAR_RENT_PUBKEY, + TransactionInstruction, +} from '@solana/web3.js'; +import { serialize } from 'borsh'; + +import { + getAuctionKeys, + getBidderKeys, + RedeemOpenEditionBidArgs, + SCHEMA, +} from '.'; + +export async function redeemOpenEditionBid( + vault: PublicKey, + store: PublicKey, + destination: PublicKey, + safetyDeposit: PublicKey, + fractionMint: PublicKey, + bidder: PublicKey, + payer: PublicKey, + instructions: TransactionInstruction[], + tokenMint: PublicKey, + masterMint: PublicKey, + transferAuthority: PublicKey, + acceptPaymentAccount: PublicKey, +) { + const PROGRAM_IDS = programIds(); + + const { auctionKey, auctionManagerKey } = await getAuctionKeys(vault); + + const { bidRedemption, bidMetadata } = await getBidderKeys( + auctionKey, + bidder, + ); + const masterMetadata: PublicKey = await getMetadata(tokenMint); + + const masterEdition: PublicKey = await getEdition(tokenMint); + + const value = new RedeemOpenEditionBidArgs(); + const data = Buffer.from(serialize(SCHEMA, value)); + const keys = [ + { + pubkey: auctionManagerKey, + isSigner: false, + isWritable: true, + }, + { + pubkey: store, + isSigner: false, + isWritable: true, + }, + { + pubkey: destination, + isSigner: false, + isWritable: true, + }, + { + pubkey: bidRedemption, + isSigner: false, + isWritable: true, + }, + { + pubkey: safetyDeposit, + isSigner: false, + isWritable: true, + }, + { + pubkey: vault, + isSigner: false, + isWritable: true, + }, + { + pubkey: fractionMint, + isSigner: false, + isWritable: true, + }, + { + pubkey: auctionKey, + isSigner: false, + isWritable: false, + }, + { + pubkey: bidMetadata, + isSigner: false, + isWritable: false, + }, + { + pubkey: bidder, + isSigner: false, + isWritable: true, + }, + { + pubkey: payer, + isSigner: true, + isWritable: false, + }, + { + pubkey: PROGRAM_IDS.token, + isSigner: false, + isWritable: false, + }, + { + pubkey: PROGRAM_IDS.vault, + isSigner: false, + isWritable: false, + }, + { + pubkey: PROGRAM_IDS.metadata, + isSigner: false, + isWritable: false, + }, + { + pubkey: SystemProgram.programId, + isSigner: false, + isWritable: false, + }, + { + pubkey: SYSVAR_RENT_PUBKEY, + isSigner: false, + isWritable: false, + }, + { + pubkey: SYSVAR_CLOCK_PUBKEY, + isSigner: false, + isWritable: false, + }, + { + pubkey: masterMetadata, + isSigner: false, + isWritable: false, + }, + { + pubkey: masterMint, + isSigner: false, + isWritable: true, + }, + { + pubkey: masterEdition, + isSigner: false, + isWritable: true, + }, + { + pubkey: transferAuthority, + isSigner: true, + isWritable: false, + }, + { + pubkey: acceptPaymentAccount, + isSigner: false, + isWritable: true, + }, + ]; + + instructions.push( + new TransactionInstruction({ + keys, + programId: PROGRAM_IDS.metaplex, + data, + }), + ); +} diff --git a/packages/metavinci/src/models/metaplex/startAuction.ts b/packages/metavinci/src/models/metaplex/startAuction.ts new file mode 100644 index 0000000..a8820ae --- /dev/null +++ b/packages/metavinci/src/models/metaplex/startAuction.ts @@ -0,0 +1,60 @@ +import { programIds } from '@oyster/common'; +import { + PublicKey, + SYSVAR_CLOCK_PUBKEY, + TransactionInstruction, +} from '@solana/web3.js'; +import { serialize } from 'borsh'; + +import { getAuctionKeys, SCHEMA, StartAuctionArgs } from '.'; + +export async function startAuction( + vault: PublicKey, + auctionManagerAuthority: PublicKey, + instructions: TransactionInstruction[], +) { + const PROGRAM_IDS = programIds(); + + const { auctionKey, auctionManagerKey } = await getAuctionKeys(vault); + + const value = new StartAuctionArgs(); + const data = Buffer.from(serialize(SCHEMA, value)); + + const keys = [ + { + pubkey: auctionManagerKey, + isSigner: false, + isWritable: true, + }, + { + pubkey: auctionKey, + isSigner: false, + isWritable: true, + }, + { + pubkey: auctionManagerAuthority, + isSigner: true, + isWritable: false, + }, + + { + pubkey: PROGRAM_IDS.auction, + isSigner: false, + isWritable: false, + }, + + { + pubkey: SYSVAR_CLOCK_PUBKEY, + isSigner: false, + isWritable: false, + }, + ]; + + instructions.push( + new TransactionInstruction({ + keys, + programId: PROGRAM_IDS.metaplex, + data, + }), + ); +} diff --git a/packages/metavinci/src/models/metaplex/validateSafetyDepositBox.ts b/packages/metavinci/src/models/metaplex/validateSafetyDepositBox.ts new file mode 100644 index 0000000..f29a3eb --- /dev/null +++ b/packages/metavinci/src/models/metaplex/validateSafetyDepositBox.ts @@ -0,0 +1,148 @@ +import { programIds, getEdition } from '@oyster/common'; +import { + PublicKey, + SystemProgram, + SYSVAR_RENT_PUBKEY, + TransactionInstruction, +} from '@solana/web3.js'; +import { serialize } from 'borsh'; + +import { + getAuctionKeys, + getOriginalAuthority, + SCHEMA, + ValidateSafetyDepositBoxArgs, +} from '.'; + +export async function validateSafetyDepositBox( + vault: PublicKey, + metadata: PublicKey, + nameSymbol: PublicKey | undefined, + safetyDepositBox: PublicKey, + store: PublicKey, + tokenMint: PublicKey, + auctionManagerAuthority: PublicKey, + metadataAuthority: PublicKey, + payer: PublicKey, + instructions: TransactionInstruction[], + masterMint?: PublicKey, + masterMintAuthority?: PublicKey, +) { + const PROGRAM_IDS = programIds(); + + const { auctionKey, auctionManagerKey } = await getAuctionKeys(vault); + + const originalAuthorityLookup: PublicKey = await getOriginalAuthority( + auctionKey, + metadata, + ); + + const edition: PublicKey = await getEdition(tokenMint); + const value = new ValidateSafetyDepositBoxArgs(); + + const data = Buffer.from(serialize(SCHEMA, value)); + const keys = [ + { + pubkey: auctionManagerKey, + isSigner: false, + isWritable: true, + }, + { + pubkey: metadata, + isSigner: false, + isWritable: true, + }, + { + pubkey: nameSymbol || SystemProgram.programId, + isSigner: false, + isWritable: true, + }, + { + pubkey: originalAuthorityLookup, + isSigner: false, + isWritable: true, + }, + { + pubkey: safetyDepositBox, + isSigner: false, + isWritable: false, + }, + { + pubkey: store, + isSigner: false, + isWritable: false, + }, + { + pubkey: tokenMint, + isSigner: false, + isWritable: false, + }, + { + pubkey: edition, + isSigner: false, + isWritable: false, + }, + { + pubkey: vault, + isSigner: false, + isWritable: false, + }, + { + pubkey: auctionManagerAuthority, + isSigner: true, + isWritable: false, + }, + { + pubkey: metadataAuthority, + isSigner: true, + isWritable: false, + }, + + { + pubkey: payer, + isSigner: true, + isWritable: false, + }, + { + pubkey: PROGRAM_IDS.metadata, + isSigner: false, + isWritable: false, + }, + { + pubkey: PROGRAM_IDS.token, + isSigner: false, + isWritable: false, + }, + { + pubkey: SystemProgram.programId, + isSigner: false, + isWritable: false, + }, + { + pubkey: SYSVAR_RENT_PUBKEY, + isSigner: false, + isWritable: false, + }, + ]; + + if (masterMint && masterMintAuthority) { + keys.push({ + pubkey: masterMint, + isSigner: false, + isWritable: true, + }); + + keys.push({ + pubkey: masterMintAuthority, + isSigner: true, + isWritable: false, + }); + } + instructions.push( + new TransactionInstruction({ + keys, + programId: PROGRAM_IDS.metaplex, + data, + }), + ); +} diff --git a/packages/metavinci/src/models/totals.ts b/packages/metavinci/src/models/totals.ts new file mode 100644 index 0000000..b3c3a06 --- /dev/null +++ b/packages/metavinci/src/models/totals.ts @@ -0,0 +1,12 @@ +export interface TotalItem { + key: string; + marketSize: number; + nativeSize: number; + name: string; +} + +export interface Totals { + marketSize: number; + numberOfAssets: number; + items: TotalItem[]; +} diff --git a/packages/metavinci/src/react-app-env.d.ts b/packages/metavinci/src/react-app-env.d.ts new file mode 100644 index 0000000..6431bc5 --- /dev/null +++ b/packages/metavinci/src/react-app-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/packages/metavinci/src/routes.tsx b/packages/metavinci/src/routes.tsx new file mode 100644 index 0000000..142559a --- /dev/null +++ b/packages/metavinci/src/routes.tsx @@ -0,0 +1,78 @@ +import React from 'react'; +import { HashRouter, Route, Switch } from 'react-router-dom'; +import { contexts } from '@oyster/common'; +import { + MarketProvider, + MetaProvider, +} from './contexts'; +import { AppLayout } from './components/Layout'; + +import { ArtCreateView, ArtistsView, ArtistView, ArtView, AuctionCreateView, AuctionView, HomeView, ArtworksView } from './views'; +import { UseWalletProvider } from 'use-wallet'; +const { WalletProvider } = contexts.Wallet; +const { ConnectionProvider } = contexts.Connection; +const { AccountsProvider } = contexts.Accounts; + +export function Routes() { + return ( + <> + + + + + + + + + + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + + + + + + + + + + + ); +} diff --git a/packages/metavinci/src/serviceWorker.ts b/packages/metavinci/src/serviceWorker.ts new file mode 100644 index 0000000..852bc17 --- /dev/null +++ b/packages/metavinci/src/serviceWorker.ts @@ -0,0 +1,146 @@ +// This optional code is used to register a service worker. +// register() is not called by default. + +// This lets the app load faster on subsequent visits in production, and gives +// it offline capabilities. However, it also means that developers (and users) +// will only see deployed updates on subsequent visits to a page, after all the +// existing tabs open on the page have been closed, since previously cached +// resources are updated in the background. + +// To learn more about the benefits of this model and instructions on how to +// opt-in, read https://bit.ly/CRA-PWA + +const isLocalhost = Boolean( + window.location.hostname === 'localhost' || + // [::1] is the IPv6 localhost address. + window.location.hostname === '[::1]' || + // 127.0.0.0/8 are considered localhost for IPv4. + window.location.hostname.match( + /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/, + ), +); + +type Config = { + onSuccess?: (registration: ServiceWorkerRegistration) => void; + onUpdate?: (registration: ServiceWorkerRegistration) => void; +}; + +export function register(config?: Config) { + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { + // The URL constructor is available in all browsers that support SW. + const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href); + if (publicUrl.origin !== window.location.origin) { + // Our service worker won't work if PUBLIC_URL is on a different origin + // from what our page is served on. This might happen if a CDN is used to + // serve assets; see https://github.com/facebook/create-react-app/issues/2374 + return; + } + + window.addEventListener('load', () => { + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; + + if (isLocalhost) { + // This is running on localhost. Let's check if a service worker still exists or not. + checkValidServiceWorker(swUrl, config); + + // Add some additional logging to localhost, pointing developers to the + // service worker/PWA documentation. + navigator.serviceWorker.ready.then(() => { + console.log( + 'This web app is being served cache-first by a service ' + + 'worker. To learn more, visit https://bit.ly/CRA-PWA', + ); + }); + } else { + // Is not localhost. Just register service worker + registerValidSW(swUrl, config); + } + }); + } +} + +function registerValidSW(swUrl: string, config?: Config) { + navigator.serviceWorker + .register(swUrl) + .then(registration => { + registration.onupdatefound = () => { + const installingWorker = registration.installing; + if (installingWorker == null) { + return; + } + installingWorker.onstatechange = () => { + if (installingWorker.state === 'installed') { + if (navigator.serviceWorker.controller) { + // At this point, the updated precached content has been fetched, + // but the previous service worker will still serve the older + // content until all client tabs are closed. + console.log( + 'New content is available and will be used when all ' + + 'tabs for this page are closed. See https://bit.ly/CRA-PWA.', + ); + + // Execute callback + if (config && config.onUpdate) { + config.onUpdate(registration); + } + } else { + // At this point, everything has been precached. + // It's the perfect time to display a + // "Content is cached for offline use." message. + console.log('Content is cached for offline use.'); + + // Execute callback + if (config && config.onSuccess) { + config.onSuccess(registration); + } + } + } + }; + }; + }) + .catch(error => { + console.error('Error during service worker registration:', error); + }); +} + +function checkValidServiceWorker(swUrl: string, config?: Config) { + // Check if the service worker can be found. If it can't reload the page. + fetch(swUrl, { + headers: { 'Service-Worker': 'script' }, + }) + .then(response => { + // Ensure service worker exists, and that we really are getting a JS file. + const contentType = response.headers.get('content-type'); + if ( + response.status === 404 || + (contentType != null && contentType.indexOf('javascript') === -1) + ) { + // No service worker found. Probably a different app. Reload the page. + navigator.serviceWorker.ready.then(registration => { + registration.unregister().then(() => { + window.location.reload(); + }); + }); + } else { + // Service worker found. Proceed as normal. + registerValidSW(swUrl, config); + } + }) + .catch(() => { + console.log( + 'No internet connection found. App is running in offline mode.', + ); + }); +} + +export function unregister() { + if ('serviceWorker' in navigator) { + navigator.serviceWorker.ready + .then(registration => { + registration.unregister(); + }) + .catch(error => { + console.error(error.message); + }); + } +} diff --git a/packages/metavinci/src/setupTests.ts b/packages/metavinci/src/setupTests.ts new file mode 100644 index 0000000..74b1a27 --- /dev/null +++ b/packages/metavinci/src/setupTests.ts @@ -0,0 +1,5 @@ +// jest-dom adds custom jest matchers for asserting on DOM nodes. +// allows you to do things like: +// expect(element).toHaveTextContent(/react/i) +// learn more: https://github.com/testing-library/jest-dom +import '@testing-library/jest-dom/extend-expect'; diff --git a/packages/metavinci/src/types/buffer-layout.d.ts b/packages/metavinci/src/types/buffer-layout.d.ts new file mode 100644 index 0000000..32e44d0 --- /dev/null +++ b/packages/metavinci/src/types/buffer-layout.d.ts @@ -0,0 +1,9 @@ +declare module 'buffer-layout' { + const bl: any; + export = bl; +} + +declare module 'jazzicon' { + const jazzicon: any; + export = jazzicon; +} diff --git a/packages/metavinci/src/types/index.ts b/packages/metavinci/src/types/index.ts new file mode 100644 index 0000000..5926494 --- /dev/null +++ b/packages/metavinci/src/types/index.ts @@ -0,0 +1,42 @@ +import { MetadataCategory } from '@oyster/common'; + +export interface Auction { + name: string; + auctionerName: string; + auctionerLink: string; + highestBid: number; + solAmt: number; + link: string; + image: string; + + endingTS: number; +} + +export interface Artist { + name: string; + link: string; + image: string; + itemsAvailable?: number; + itemsSold?: number; + about?: string; +} + +export interface Art { + image: string; + category: MetadataCategory; + link: string; + title: string; + artist: string; + priceSOL: number; + priceUSD?: number; + endingTS?: number; + royalties?: number; + about?: string; +} + +export interface Presale { + endingTS: number; + targetPricePerShare?: number; + pricePerShare?: number; + marketCap?: number; +} diff --git a/packages/metavinci/src/types/sol-wallet-adapter.d.ts b/packages/metavinci/src/types/sol-wallet-adapter.d.ts new file mode 100644 index 0000000..41acf5d --- /dev/null +++ b/packages/metavinci/src/types/sol-wallet-adapter.d.ts @@ -0,0 +1,4 @@ +declare module '@project-serum/sol-wallet-adapter' { + const adapter: any; + export = adapter; +} diff --git a/packages/metavinci/src/utils/assets.ts b/packages/metavinci/src/utils/assets.ts new file mode 100644 index 0000000..23fb2cc --- /dev/null +++ b/packages/metavinci/src/utils/assets.ts @@ -0,0 +1,89 @@ +import { + getTokenName, + getVerboseTokenName, + KnownTokenMap, +} from '@oyster/common'; +import { TokenInfo } from '@solana/spl-token-registry'; +import { COINGECKO_COIN_PRICE_API } from '../contexts/coingecko'; + +export const getAssetName = ( + parsedAssetAddress: string, + assetChain: number, + solanaTokens: KnownTokenMap, + ethTokens: KnownTokenMap, +) => { + if (assetChain === ASSET_CHAIN.Solana) + return getVerboseTokenName(solanaTokens, parsedAssetAddress); + else return getVerboseTokenName(ethTokens, `0x${parsedAssetAddress}`); +}; + +export const LAMPORT_MULTIPLIER = 10 ** 9; +const WINSTON_MULTIPLIER = 10 ** 12; + +export const getAssetTokenSymbol = ( + parsedAssetAddress: string, + assetChain: number, + solanaTokens: KnownTokenMap, + ethTokens: KnownTokenMap, +) => { + if (assetChain === ASSET_CHAIN.Solana) + return getTokenName(solanaTokens, parsedAssetAddress); + else return getTokenName(ethTokens, `0x${parsedAssetAddress}`); +}; + +export const solanaToUSD = async (amount: number): Promise => { + const url = `${COINGECKO_COIN_PRICE_API}?ids=solana&vs_currencies=usd` + const resp = await window.fetch(url).then(resp => resp.json()) + return amount * resp.solana.usd +} + +export enum ASSET_CHAIN { + Solana = 1, + Ethereum = 2, +} + +const CHAIN_NAME = { + [ASSET_CHAIN.Solana]: 'Solana', + [ASSET_CHAIN.Ethereum]: 'Ethereum', +}; + +export const chainToName = (chain?: ASSET_CHAIN) => { + return CHAIN_NAME[chain || ASSET_CHAIN.Ethereum]; +}; + +export const filterModalSolTokens = (tokens: TokenInfo[]) => { + return tokens; +}; + +export async function getAssetCostToStore(files: File[]) { + const totalBytes = files.reduce((sum, f) => (sum += f.size), 0); + console.log('Total bytes', totalBytes); + const txnFeeInWinstons = parseInt( + await (await fetch('https://arweave.net/price/0')).text(), + ); + console.log('txn fee', txnFeeInWinstons); + const byteCostInWinstons = parseInt( + await ( + await fetch('https://arweave.net/price/' + totalBytes.toString()) + ).text(), + ); + console.log('byte cost', byteCostInWinstons); + const totalArCost = + (txnFeeInWinstons * files.length + byteCostInWinstons) / WINSTON_MULTIPLIER; + + console.log('total ar', totalArCost); + const conversionRates = JSON.parse( + await ( + await fetch( + 'https://api.coingecko.com/api/v3/simple/price?ids=solana,arweave&vs_currencies=usd', + ) + ).text(), + ); + + // To figure out how many lamports are required, multiply ar byte cost by this number + const arMultiplier = conversionRates.arweave.usd / conversionRates.solana.usd; + console.log('Ar mult', arMultiplier); + // Add 10% padding for safety and slippage in price. + // We also always make a manifest file, which, though tiny, needs payment. + return LAMPORT_MULTIPLIER * totalArCost * arMultiplier * 1.1; +} diff --git a/packages/metavinci/src/utils/ids.ts b/packages/metavinci/src/utils/ids.ts new file mode 100644 index 0000000..2b2e9b7 --- /dev/null +++ b/packages/metavinci/src/utils/ids.ts @@ -0,0 +1,18 @@ +import { PublicKey } from '@solana/web3.js'; + +export const AUCTION_PROGRAM_ID = new PublicKey( + 'C9nHkL6BfGx9M9MyYrJqAD5hPsGJd1fHpp1uAJA6vTCn', +); + +export const VAULT_PROGRAM_ID = new PublicKey( + '94wRaYAQdC2gYF76AUTYSugNJ3rAC4EimjAMPwM7uYry', +); + +export const METAPLEX_PROGRAM_ID = new PublicKey( + 'EPtpKdKW8qciGVd1UFyGjgbBHTbSAyvbY61h9uQGVgeu', +); + +// TODO: generate key --- +export const AR_SOL_HOLDER_ID = new PublicKey( + 'HvwC9QSAzvGXhhVrgPmauVwFWcYZhne3hVot9EbHuFTm', +); diff --git a/packages/metavinci/src/utils/layout.ts b/packages/metavinci/src/utils/layout.ts new file mode 100644 index 0000000..38931a4 --- /dev/null +++ b/packages/metavinci/src/utils/layout.ts @@ -0,0 +1,121 @@ +import { PublicKey } from '@solana/web3.js'; +import BN from 'bn.js'; +import * as BufferLayout from 'buffer-layout'; + +/** + * Layout for a public key + */ +export const publicKey = (property = 'publicKey'): unknown => { + const publicKeyLayout = BufferLayout.blob(32, property); + + const _decode = publicKeyLayout.decode.bind(publicKeyLayout); + const _encode = publicKeyLayout.encode.bind(publicKeyLayout); + + publicKeyLayout.decode = (buffer: Buffer, offset: number) => { + const data = _decode(buffer, offset); + return new PublicKey(data); + }; + + publicKeyLayout.encode = (key: PublicKey, buffer: Buffer, offset: number) => { + return _encode(key.toBuffer(), buffer, offset); + }; + + return publicKeyLayout; +}; + +/** + * Layout for a 64bit unsigned value + */ +export const uint64 = (property = 'uint64'): unknown => { + const layout = BufferLayout.blob(8, property); + + const _decode = layout.decode.bind(layout); + const _encode = layout.encode.bind(layout); + + layout.decode = (buffer: Buffer, offset: number) => { + const data = _decode(buffer, offset); + return new BN( + [...data] + .reverse() + .map(i => `00${i.toString(16)}`.slice(-2)) + .join(''), + 16, + ); + }; + + layout.encode = (num: BN, buffer: Buffer, offset: number) => { + const a = num.toArray().reverse(); + let b = Buffer.from(a); + if (b.length !== 8) { + const zeroPad = Buffer.alloc(8); + b.copy(zeroPad); + b = zeroPad; + } + return _encode(b, buffer, offset); + }; + + return layout; +}; + +// TODO: wrap in BN (what about decimals?) +export const uint128 = (property = 'uint128'): unknown => { + const layout = BufferLayout.blob(16, property); + + const _decode = layout.decode.bind(layout); + const _encode = layout.encode.bind(layout); + + layout.decode = (buffer: Buffer, offset: number) => { + const data = _decode(buffer, offset); + return new BN( + [...data] + .reverse() + .map(i => `00${i.toString(16)}`.slice(-2)) + .join(''), + 16, + ); + }; + + layout.encode = (num: BN, buffer: Buffer, offset: number) => { + const a = num.toArray().reverse(); + let b = Buffer.from(a); + if (b.length !== 16) { + const zeroPad = Buffer.alloc(16); + b.copy(zeroPad); + b = zeroPad; + } + + return _encode(b, buffer, offset); + }; + + return layout; +}; + +/** + * Layout for a Rust String type + */ +export const rustString = (property = 'string'): unknown => { + const rsl = BufferLayout.struct( + [ + BufferLayout.u32('length'), + BufferLayout.u32('lengthPadding'), + BufferLayout.blob(BufferLayout.offset(BufferLayout.u32(), -8), 'chars'), + ], + property, + ); + const _decode = rsl.decode.bind(rsl); + const _encode = rsl.encode.bind(rsl); + + rsl.decode = (buffer: Buffer, offset: number) => { + const data = _decode(buffer, offset); + return data.chars.toString('utf8'); + }; + + rsl.encode = (str: string, buffer: Buffer, offset: number) => { + const data = { + chars: Buffer.from(str, 'utf8'), + }; + return _encode(data, buffer, offset); + }; + + return rsl; +}; diff --git a/packages/metavinci/src/utils/utils.ts b/packages/metavinci/src/utils/utils.ts new file mode 100644 index 0000000..ac6044b --- /dev/null +++ b/packages/metavinci/src/utils/utils.ts @@ -0,0 +1,25 @@ +import moment from 'moment'; + +export const getCountdown = (ts: number) => { + const now = moment().unix(); + let delta = ts - now; + + if (!ts || delta <= 0) return { days: 0, hours: 0, minutes: 0, seconds: 0 }; + + const days = Math.floor(delta / 86400); + delta -= days * 86400; + + const hours = Math.floor(delta / 3600) % 24; + delta -= hours * 3600; + + const minutes = Math.floor(delta / 60) % 60; + delta -= minutes * 60; + + const seconds = Math.floor(delta % 60); + + return { days, hours, minutes, seconds }; +}; + +export const cleanName = (name: string): string => { + return name.replaceAll(' ', '-'); +}; diff --git a/packages/metavinci/src/views/art/index.less b/packages/metavinci/src/views/art/index.less new file mode 100644 index 0000000..78155f7 --- /dev/null +++ b/packages/metavinci/src/views/art/index.less @@ -0,0 +1,32 @@ + +.artwork-image { + margin: 30px auto; + width: 70%; + max-width: 500px; + border-radius: 10px; + overflow: hidden; +} + +.artist-image { + width: 35px; + border-radius: 50%; +} + +.info-header { + font-size: 1rem; + font-style: normal; + font-weight: normal; + margin-bottom: 1vh; + letter-spacing: 0.1em; + text-transform: uppercase; + color: rgba(255, 255, 255, 0.7); +} + +.info-content { + width: 90%; +} + +.royalties { + font-weight: 700; + font-size: 2rem; +} diff --git a/packages/metavinci/src/views/art/index.tsx b/packages/metavinci/src/views/art/index.tsx new file mode 100644 index 0000000..94c1cb4 --- /dev/null +++ b/packages/metavinci/src/views/art/index.tsx @@ -0,0 +1,45 @@ +import React from 'react'; +import { Row, Col, Divider, Layout } from 'antd'; +import { useParams } from 'react-router-dom'; +import { useArt } from './../../hooks'; + +import "./index.less" +import { Artist } from '../../types'; +import { sampleArtist } from '../home/sampleData'; +import { ArtContent } from '../../components/ArtContent'; + +const { Content } = Layout + +export const ArtView = () => { + const { id } = useParams<{ id: string }>(); + const art = useArt(id); + const artist: Artist = sampleArtist + + return ( + + + + + + + + +
{art.title}
+
+
CREATED BY
+
@{art.artist}
+
+
CREATOR ROYALTIES
+
{art.royalties}%
+
+
ABOUT THE CREATION
+
{art.about}
+
+
ABOUT THE CREATOR
+
{artist.about}
+ + + + + ); +}; diff --git a/packages/metavinci/src/views/artCreate/index.tsx b/packages/metavinci/src/views/artCreate/index.tsx new file mode 100644 index 0000000..e4fe649 --- /dev/null +++ b/packages/metavinci/src/views/artCreate/index.tsx @@ -0,0 +1,802 @@ +import React, { useEffect, useState } from 'react'; +import { + Steps, + Row, + Button, + Upload, + Col, + Input, + Statistic, + Slider, + Progress, + Spin, + InputNumber, + Select, +} from 'antd'; +import { ArtCard } from './../../components/ArtCard'; +import { UserSearch, UserValue } from './../../components/UserSearch'; +import { Confetti } from './../../components/Confetti'; +import './../styles.less'; +import { mintNFT } from '../../actions'; +import { + MAX_METADATA_LEN, + MAX_NAME_SYMBOL_LEN, + MAX_URI_LENGTH, + useConnection, + useWallet, + IMetadataExtension, + MetadataCategory, + useConnectionConfig, +} from '@oyster/common'; +import { + getAssetCostToStore, + LAMPORT_MULTIPLIER, + solanaToUSD, +} from '../../utils/assets'; +import { Connection, PublicKey } from '@solana/web3.js'; +import { MintLayout } from '@solana/spl-token'; +import { useHistory, useParams } from 'react-router-dom'; +import { cleanName } from '../../utils/utils'; + +const { Step } = Steps; +const { Option } = Select; +const { Dragger } = Upload; + +export const ArtCreateView = () => { + const connection = useConnection(); + const { env } = useConnectionConfig(); + const { wallet, connected } = useWallet(); + const { step_param }: { step_param: string } = useParams(); + const history = useHistory(); + + const [step, setStep] = useState(0); + const [saving, setSaving] = useState(false); + const [progress, setProgress] = useState(0); + const [nft, setNft] = useState<{ metadataAccount: PublicKey } | undefined>(undefined); + const [attributes, setAttributes] = useState({ + name: '', + symbol: '', + description: '', + externalUrl: '', + image: '', + royalty: 0, + files: [], + category: MetadataCategory.Image, + }); + + useEffect(() => { + if (step_param) setStep(parseInt(step_param)); + else gotoStep(0); + }, [step_param]); + + const gotoStep = (_step: number) => { + history.push(`/art/create/${_step.toString()}`); + }; + + // store files + const mint = async () => { + const metadata = { + ...(attributes as any), + image: + attributes.files && attributes.files?.[0] && attributes.files[0].name, + files: (attributes?.files || []).map(f => f.name), + }; + setSaving(true); + const inte = setInterval(() => setProgress(prog => prog + 1), 600); + // Update progress inside mintNFT + const _nft = await mintNFT(connection, wallet, env, attributes?.files || [], metadata); + if (_nft) setNft(_nft) + clearInterval(inte); + }; + + return ( + <> + + {!saving && ( + + + + + + + + + + )} + + {step === 0 && ( + { + setAttributes({ + ...attributes, + category, + }); + gotoStep(1); + }} + /> + )} + {step === 1 && ( + gotoStep(2)} + /> + )} + + {step === 2 && ( + gotoStep(3)} + /> + )} + {step === 3 && ( + gotoStep(4)} + setAttributes={setAttributes} + /> + )} + {step === 4 && ( + gotoStep(5)} + connection={connection} + /> + )} + {step === 5 && ( + gotoStep(6)} + /> + )} + {step === 6 && } + {0 < step && step < 5 && ( + + )} + + + + ); +}; + +const CategoryStep = (props: { + confirm: (category: MetadataCategory) => void; +}) => { + return ( + <> + +

Create a new item

+

+ First time creating on Metaplex? Read our creators’ guide. +

+
+ +
+ + + + + + + + + + + + + + + + ); +}; + +const UploadStep = (props: { + attributes: IMetadataExtension; + setAttributes: (attr: IMetadataExtension) => void; + confirm: () => void; +}) => { + const [mainFile, setMainFile] = useState(); + const [coverFile, setCoverFile] = useState(); + const [image, setImage] = useState(''); + + useEffect(() => { + props.setAttributes({ + ...props.attributes, + files: [], + }); + }, []); + + const uploadMsg = (category: MetadataCategory) => { + switch (category) { + case MetadataCategory.Audio: + return 'Upload your audio creation (MP3, FLAC, WAV)'; + case MetadataCategory.Image: + return 'Upload your image creation (PNG, JPG, GIF)'; + case MetadataCategory.Video: + return 'Upload your video creation (MP4)'; + default: + return 'Please go back and choose a category'; + } + }; + + return ( + <> + +

Now, let's upload your creation

+

+ Your file will be uploaded to the decentralized web via Arweave. + Depending on file type, can take up to 1 minute. Arweave is a new type + of storage that backs data with sustainable and perpetual endowments, + allowing users and developers to truly store data forever – for the + very first time. +

+
+ +

{uploadMsg(props.attributes.category)}

+ { + // dont upload files here, handled outside of the control + info?.onSuccess?.({}, null as any); + }} + fileList={mainFile ? [mainFile] : []} + onChange={async info => { + const file = info.file.originFileObj; + if (file) setMainFile(file); + if (props.attributes.category != MetadataCategory.Audio) { + const reader = new FileReader(); + reader.onload = function (event) { + setImage((event.target?.result as string) || ''); + }; + if (file) reader.readAsDataURL(file); + } + }} + > +
+

Upload your creation

+
+

Drag and drop, or click to browse

+
+
+ {props.attributes.category == MetadataCategory.Audio && ( + +

+ Optionally, you can upload a cover image or video (PNG, JPG, GIF, + MP4) +

+ { + // dont upload files here, handled outside of the control + info?.onSuccess?.({}, null as any); + }} + fileList={coverFile ? [coverFile] : []} + onChange={async info => { + const file = info.file.originFileObj; + if (file) setCoverFile(file); + if (props.attributes.category == MetadataCategory.Audio) { + const reader = new FileReader(); + reader.onload = function (event) { + setImage((event.target?.result as string) || ''); + }; + if (file) reader.readAsDataURL(file); + } + }} + > +
+

+ Upload your cover image or video +

+
+

Drag and drop, or click to browse

+
+
+ )} + + + + + ); +}; + +interface Royalty { + creator_key: string; + amount: number; +} + +const InfoStep = (props: { + attributes: IMetadataExtension; + setAttributes: (attr: IMetadataExtension) => void; + confirm: () => void; +}) => { + const [creators, setCreators] = useState>([]); + const [royalties, setRoyalties] = useState>([]); + + useEffect(() => { + setRoyalties( + creators.map(creator => ({ + creator_key: creator.key, + amount: Math.trunc(100 / creators.length), + })), + ); + }, [creators]); + + return ( + <> + +

Describe your item

+

+ Provide detailed description of your creative process to engage with + your audience. +

+
+ +
+ {props.attributes.image && ( + + )} + + + + + + + + + + + + + + + + ); +}; + +const shuffle = (array: Array) => { + array.sort(() => Math.random() - 0.5); +}; + +const RoyaltiesSplitter = (props: { + creators: Array; + royalties: Array; + setRoyalties: Function; +}) => { + return ( + + {props.creators.map((creator, idx) => { + const royalty = props.royalties.find( + royalty => royalty.creator_key == creator.key, + ); + if (!royalty) return null; + + const amt = royalty.amount; + const handleSlide = (newAmt: number) => { + const othersRoyalties = props.royalties.filter( + _royalty => _royalty.creator_key != royalty.creator_key, + ); + if (othersRoyalties.length < 1) return; + shuffle(othersRoyalties); + const others_n = props.royalties.length - 1; + const sign = Math.sign(newAmt - amt); + let remaining = Math.abs(newAmt - amt); + let count = 0; + while (remaining > 0 && count < 100) { + const idx = count % others_n; + const _royalty = othersRoyalties[idx]; + if ( + (0 < _royalty.amount && _royalty.amount < 100) || // Normal + (_royalty.amount == 0 && sign < 0) || // Low limit + (_royalty.amount == 100 && sign > 0) // High limit + ) { + _royalty.amount -= sign; + remaining -= 1; + } + count += 1; + } + + props.setRoyalties( + props.royalties.map(_royalty => { + const computed_amount = othersRoyalties.find( + newRoyalty => newRoyalty.creator_key == _royalty.creator_key, + )?.amount; + return { + ..._royalty, + amount: + _royalty.creator_key == royalty.creator_key + ? newAmt + : computed_amount, + }; + }), + ); + }; + return ( + + + {creator.label} + + + {amt}% + + + + + + ); + })} + + ); +}; + +const RoyaltiesStep = (props: { + attributes: IMetadataExtension; + setAttributes: (attr: IMetadataExtension) => void; + confirm: () => void; +}) => { + const file = props.attributes.image; + + return ( + <> + +

Set royalties for the creation

+

+ A royalty is a payment made by the seller of this item to the creator. + It is charged after every successful auction. +

+
+ +
+ {file && ( + + )} + + + + + + + + + + ); +}; + +const LaunchStep = (props: { + confirm: () => void; + attributes: IMetadataExtension; + connection: Connection; +}) => { + const files = props.attributes.files || []; + const metadata = { + ...(props.attributes as any), + files: files.map(f => f?.name), + }; + const [cost, setCost] = useState(0); + const [USDcost, setUSDcost] = useState(0); + useEffect(() => { + const rentCall = Promise.all([ + props.connection.getMinimumBalanceForRentExemption(MintLayout.span), + props.connection.getMinimumBalanceForRentExemption(MAX_METADATA_LEN), + props.connection.getMinimumBalanceForRentExemption(MAX_NAME_SYMBOL_LEN), + ]); + + getAssetCostToStore([ + ...files, + new File([JSON.stringify(metadata)], 'metadata.json'), + ]).then(async lamports => { + const sol = lamports / LAMPORT_MULTIPLIER; + + // TODO: cache this and batch in one call + const [mintRent, metadataRent, nameSymbolRent] = await rentCall; + + const uriStr = 'x'; + let uriBuilder = ''; + for (let i = 0; i < MAX_URI_LENGTH; i++) { + uriBuilder += uriStr; + } + + const additionalSol = + (metadataRent + nameSymbolRent + mintRent) / LAMPORT_MULTIPLIER; + + // TODO: add fees based on number of transactions and signers + setCost(sol + additionalSol); + }); + }, [...files, setCost]); + + useEffect(() => { + cost && solanaToUSD(cost).then(setUSDcost); + }, [cost]); + + return ( + <> + +

Launch your creation

+

+ Provide detailed description of your creative process to engage with + your audience. +

+
+ + + {props.attributes.image && ( + + )} + + + + {cost ? ( +
+ +
+ ${USDcost.toPrecision(2)} +
+
+ ) : ( + + )} + + + + + + + + ); +}; + +const WaitingStep = (props: { + mint: Function; + progress: number; + confirm: Function; +}) => { + useEffect(() => { + const func = async () => { + await props.mint(); + props.confirm(); + }; + func(); + }, []); + + return ( +
+ +
+ Your creation is being uploaded to the decentralized web... +
+
This can take up to 1 minute.
+
+ ); +}; + +const Congrats = (props: { + nft?: { + metadataAccount: PublicKey, + } +}) => { + + const history = useHistory() + + const newTweetURL = () => { + const params = { + text: "I've created a new NFT artwork on Metaplex, check it out!", + url: `${window.location.origin}/#/art/${props.nft?.metadataAccount.toString()}`, + hashtags: "NFT,Crypto,Metaplex", + // via: "Metaplex", + related: "Metaplex,Solana", + } + const queryParams = new URLSearchParams(params).toString() + return `https://twitter.com/intent/tweet?${queryParams}` + } + + return ( + <> +
+
+ Congratulations, you created an NFT! +
+
+ + + +
+
+ + + ); +}; diff --git a/packages/metavinci/src/views/artist/index.tsx b/packages/metavinci/src/views/artist/index.tsx new file mode 100644 index 0000000..9791f14 --- /dev/null +++ b/packages/metavinci/src/views/artist/index.tsx @@ -0,0 +1,9 @@ +import React from 'react'; + +export const ArtistView = () => { + return ( +
+ TODO: Artist view +
+ ); +}; diff --git a/packages/metavinci/src/views/artists/index.tsx b/packages/metavinci/src/views/artists/index.tsx new file mode 100644 index 0000000..cd0cef5 --- /dev/null +++ b/packages/metavinci/src/views/artists/index.tsx @@ -0,0 +1,9 @@ +import React from 'react'; + +export const ArtistsView = () => { + return ( +
+ TODO: Artists view +
+ ); +}; diff --git a/packages/metavinci/src/views/artworks/index.tsx b/packages/metavinci/src/views/artworks/index.tsx new file mode 100644 index 0000000..cf3df02 --- /dev/null +++ b/packages/metavinci/src/views/artworks/index.tsx @@ -0,0 +1,85 @@ +import React, { useState } from 'react'; +import { ArtCard } from '../../components/ArtCard'; +import { Layout, Row, Col, Tabs } from 'antd'; +import Masonry from 'react-masonry-css'; +import { Link } from 'react-router-dom'; +import { useUserArts } from '../../hooks'; +import { useMeta } from '../../contexts'; + +const { TabPane } = Tabs; + +const { Content } = Layout; + + +export enum ArtworkViewState { + Metaplex = '0', + Owned = '1', + Created = '2', +} + +export const ArtworksView = () => { + const ownedMetadata = useUserArts(); + const { metadata } = useMeta(); + const [activeKey, setActiveKey] = useState(ArtworkViewState.Metaplex); + const breakpointColumnsObj = { + default: 4, + 1100: 3, + 700: 2, + 500: 1, + }; + + const items = activeKey === ArtworkViewState.Metaplex ? metadata : ownedMetadata.map(m => m.metadata); + + const artworkGrid = + {items.map(m => { + const id = m.pubkey.toBase58(); + return ( + + + + ); + })} + ; + + return ( + + +
+ + setActiveKey(key as ArtworkViewState)} + > + All} + key={ArtworkViewState.Metaplex} + > + {artworkGrid} + + Created} + key={ArtworkViewState.Created} + > + {artworkGrid} + + Owned} + key={ArtworkViewState.Owned} + > + {artworkGrid} + + + + + + + ); +}; diff --git a/packages/metavinci/src/views/auction/index.tsx b/packages/metavinci/src/views/auction/index.tsx new file mode 100644 index 0000000..de4bf1c --- /dev/null +++ b/packages/metavinci/src/views/auction/index.tsx @@ -0,0 +1,55 @@ +import React from 'react'; +import { useParams } from 'react-router-dom'; +import { Row, Col, Divider, Layout, Image, Spin } from 'antd'; +import { AuctionCard } from '../../components/AuctionCard'; +import { metadataToArt, useArt, useAuction } from '../../hooks'; +import { ArtContent } from '../../components/ArtContent'; +import { sampleArtist } from '../home/sampleData'; + +const { Content } = Layout; + +export const AuctionView = () => { + const { id } = useParams<{ id: string }>(); + const auction = useAuction(id); + const art = useArt(auction?.thumbnail.metadata.pubkey); + const artist = sampleArtist; + + return ( + + + + + + + + +
{art.title}
+
+
CREATED BY
+
+ @{art.artist} +
+
+
CREATOR ROYALTIES
+
{art.royalties}%
+
+
ABOUT THE CREATION
+
{art.about}
+
+
ABOUT THE CREATOR
+
{artist.about}
+ + + {auction ? : } + + + + + ); +}; diff --git a/packages/metavinci/src/views/auctionCreate/artSelector.tsx b/packages/metavinci/src/views/auctionCreate/artSelector.tsx new file mode 100644 index 0000000..7725d6c --- /dev/null +++ b/packages/metavinci/src/views/auctionCreate/artSelector.tsx @@ -0,0 +1,157 @@ +import React, { useEffect, useMemo, useState } from 'react'; +import { Row, Button, Modal, ButtonProps } from 'antd'; +import { ArtCard } from './../../components/ArtCard'; +import './../styles.less'; +import { Metadata, ParsedAccount } from '@oyster/common'; +import { useArt, useUserArts } from '../../hooks'; +import Masonry from 'react-masonry-css'; +import { SafetyDepositDraft } from '../../actions/createAuctionManager'; + +export interface ArtSelectorProps extends ButtonProps { + selected: SafetyDepositDraft[]; + setSelected: (selected: SafetyDepositDraft[]) => void; + allowMultiple: boolean; + filter?: (i: SafetyDepositDraft) => boolean; +} + +export const ArtSelector = (props: ArtSelectorProps) => { + const { selected, setSelected, allowMultiple, ...rest } = props; + let items = useUserArts(); + if (props.filter) items = items.filter(props.filter); + const selectedItems = useMemo>( + () => new Set(selected.map(item => item.metadata.pubkey.toBase58())), + [selected], + ); + + const [visible, setVisible] = useState(false); + + const open = () => { + clear(); + + setVisible(true); + }; + + const close = () => { + setVisible(false); + }; + + const clear = () => { + setSelected([]); + }; + + const confirm = () => { + close(); + }; + + const breakpointColumnsObj = { + default: 4, + 1100: 3, + 700: 2, + 500: 1, + }; + + return ( + <> + + {selected.map(m => { + let key = m?.metadata.pubkey.toBase58() || ''; + + return ( + { + setSelected( + selected.filter(_ => _.metadata.pubkey.toBase58() !== key), + ); + confirm(); + }} + /> + ); + })} + {(allowMultiple || selectedItems.size === 0) && ( +
+ Add an NFT +
+ )} +
+ + + +

Select the NFT you want to sell

+

+ Select the NFT that you want to sell copy/copies of. +

+
+ + + {items.map(m => { + const id = m.metadata.pubkey.toBase58(); + const isSelected = selectedItems.has(id); + + const onSelect = () => { + let list = [...selectedItems.keys()]; + if (allowMultiple) { + list = []; + } + + const newSet = isSelected + ? new Set(list.filter(item => item !== id)) + : new Set([...list, id]); + + let selected = items.filter(item => + newSet.has(item.metadata.pubkey.toBase58()), + ); + setSelected(selected); + + if (!allowMultiple) { + confirm(); + } + }; + + return ( + + ); + })} + + + + + +
+ + ); +}; diff --git a/packages/metavinci/src/views/auctionCreate/index.tsx b/packages/metavinci/src/views/auctionCreate/index.tsx new file mode 100644 index 0000000..49cdcbd --- /dev/null +++ b/packages/metavinci/src/views/auctionCreate/index.tsx @@ -0,0 +1,1557 @@ +import React, { useEffect, useMemo, useState } from 'react'; +import { + Divider, + Steps, + Row, + Button, + Upload, + Col, + Input, + Statistic, + Modal, + Progress, + Spin, + InputNumber, + Select, + TimePicker, + DatePicker, + Radio, +} from 'antd'; +import { ArtCard } from './../../components/ArtCard'; +import { UserSearch, UserValue } from './../../components/UserSearch'; +import { Confetti } from './../../components/Confetti'; +import { ArtSelector } from './artSelector'; +import './../styles.less'; +import { + MAX_METADATA_LEN, + MAX_NAME_SYMBOL_LEN, + useConnection, + useWallet, + useConnectionConfig, + Metadata, + ParsedAccount, + deserializeBorsh, + WinnerLimit, + WinnerLimitType, +} from '@oyster/common'; +import { getAssetCostToStore, LAMPORT_MULTIPLIER } from '../../utils/assets'; +import { Connection, ParsedAccountData, PublicKey } from '@solana/web3.js'; +import { MintLayout, TOKEN_PROGRAM_ID } from '@solana/spl-token'; +import { useHistory, useParams } from 'react-router-dom'; +import { useUserArts } from '../../hooks'; +import Masonry from 'react-masonry-css'; +import { capitalize } from 'lodash'; +import { + AuctionManager, + AuctionManagerSettings, + AuctionManagerState, + AuctionManagerStatus, + EditionType, + NonWinningConstraint, + SCHEMA, + WinningConfig, + WinningConstraint, +} from '../../models/metaplex'; +import { serialize } from 'borsh'; +import moment from 'moment'; +import { + createAuctionManager, + SafetyDepositDraft, +} from '../../actions/createAuctionManager'; +import BN from 'bn.js'; +import { ZERO } from '@oyster/common/dist/lib/constants'; + +const { Step } = Steps; +const { Option } = Select; +const { Dragger } = Upload; +const { TextArea } = Input; + +export enum AuctionCategory { + Limited, + Single, + Open, + Tiered, +} + +interface Tier { + to: number; + name: string; + description?: string; + items: SafetyDepositDraft[]; +} + +export interface AuctionState { + // Min price required for the item to sell + reservationPrice: number; + + // listed NFTs + items: SafetyDepositDraft[]; + participationNFT?: SafetyDepositDraft; + // number of editions for this auction (only applicable to limited edition) + editions?: number; + + // date time when auction should start UTC+0 + startDate?: Date; + + // suggested date time when auction should end UTC+0 + endDate?: Date; + + ////////////////// + category: AuctionCategory; + saleType?: 'auction' | 'sale'; + + price?: number; + priceFloor?: number; + priceTick?: number; + + startSaleTS?: number; // Why do I prefer to work with unix ts? + startListTS?: number; + endTS?: number; + + auctionDuration?: number; + gapTime?: number; + tickSizeEndingPhase?: number; + + spots?: number; + tiers?: Array; + + winnersCount: number; +} + +export const AuctionCreateView = () => { + const connection = useConnection(); + const { env } = useConnectionConfig(); + const items = useUserArts(); + const { wallet, connected } = useWallet(); + const { step_param }: { step_param: string } = useParams(); + const history = useHistory(); + + const [step, setStep] = useState(0); + const [saving, setSaving] = useState(false); + const [auctionObj, setAuctionObj] = useState<{ + vault: PublicKey; + auction: PublicKey; + auctionManager: PublicKey; + } | undefined>(undefined); + const [attributes, setAttributes] = useState({ + reservationPrice: 0, + items: [], + category: AuctionCategory.Open, + saleType: 'auction', + winnersCount: 1, + }); + + useEffect(() => { + if (step_param) setStep(parseInt(step_param)); + else gotoNextStep(0); + }, [step_param]); + + const gotoNextStep = (_step?: number) => { + const nextStep = _step === undefined ? step + 1 : _step; + history.push(`/auction/create/${nextStep.toString()}`); + }; + + const createAuction = async () => { + let settings: AuctionManagerSettings; + let winnerLimit: WinnerLimit; + if (attributes.category == AuctionCategory.Open) { + settings = new AuctionManagerSettings({ + openEditionWinnerConstraint: WinningConstraint.OpenEditionGiven, + openEditionNonWinningConstraint: + NonWinningConstraint.GivenForFixedPrice, + winningConfigs: [], + openEditionConfig: 0, + openEditionFixedPrice: new BN(attributes.reservationPrice), + }); + + winnerLimit = new WinnerLimit({ + type: WinnerLimitType.Unlimited, + usize: ZERO, + }); + } else if ( + attributes.category == AuctionCategory.Limited || + attributes.category == AuctionCategory.Single + ) { + settings = new AuctionManagerSettings({ + openEditionWinnerConstraint: attributes.participationNFT + ? WinningConstraint.OpenEditionGiven + : WinningConstraint.NoOpenEdition, + openEditionNonWinningConstraint: attributes.participationNFT + ? NonWinningConstraint.GivenForFixedPrice + : NonWinningConstraint.NoOpenEdition, + winningConfigs: attributes.items.map( + (item, index) => + new WinningConfig({ + // TODO: check index + safetyDepositBoxIndex: index, + amount: 1, + editionType: + attributes.category == AuctionCategory.Limited + ? EditionType.LimitedEdition + : item.masterEdition + ? EditionType.MasterEdition + : EditionType.NA, + }), + ), + openEditionConfig: attributes.participationNFT + ? attributes.items.length + : null, + openEditionFixedPrice: attributes.participationNFT + ? new BN(attributes.reservationPrice) + : null, + }); + winnerLimit = new WinnerLimit({ + type: WinnerLimitType.Capped, + usize: new BN(attributes.winnersCount), + }); + console.log('Settings', settings); + } else { + throw new Error('Not supported'); + } + + const endAuctionAt = moment().unix() + ((attributes.auctionDuration || 0) * 60) + + const _auctionObj = await createAuctionManager( + connection, + wallet, + settings, + winnerLimit, + new BN(endAuctionAt), + new BN((attributes.gapTime || 0) * 60), + [ + ...attributes.items, + ...(attributes.participationNFT ? [attributes.participationNFT] : []), + ], + // TODO: move to config + new PublicKey('3EVo6RQfu5D1DC18jsqrQnbiKLYoig8yckJC7QgMiJVY'), + ); + setAuctionObj(_auctionObj) + }; + + const categoryStep = ( + { + setAttributes({ + ...attributes, + category, + }); + gotoNextStep(); + }} + /> + ); + + const copiesStep = ( + gotoNextStep()} + /> + ); + + const winnersStep = ( + gotoNextStep()} + /> + ); + + const tierStep = ( + gotoNextStep()} + /> + ); + + const typeStep = ( + gotoNextStep()} + /> + ); + + const priceStep = ( + gotoNextStep()} + /> + ); + + const initialStep = ( + gotoNextStep()} + /> + ); + + const endingStep = ( + gotoNextStep()} + /> + ); + + const participationStep = ( + gotoNextStep()} + /> + ); + + const reviewStep = ( + { + setSaving(true) + gotoNextStep() + }} + connection={connection} + /> + ); + + const waitStep = ( + gotoNextStep()} + /> + ); + + const congratsStep = ; + + const stepsByCategory = { + [AuctionCategory.Limited]: [ + ['Category', categoryStep], + ['Copies', copiesStep], + ['Sale Type', typeStep], + ['Price', priceStep], + ['Initial Phase', initialStep], + ['Ending Phase', endingStep], + ['Participation NFT', participationStep], + ['Review', reviewStep], + ['Publish', waitStep], + [undefined, congratsStep], + ], + [AuctionCategory.Single]: [ + ['Category', categoryStep], + ['Copies', copiesStep], + ['Price', priceStep], + ['Initial Phase', initialStep], + ['Ending Phase', endingStep], + ['Participation NFT', participationStep], + ['Review', reviewStep], + ['Publish', waitStep], + [undefined, congratsStep], + ], + [AuctionCategory.Open]: [ + ['Category', categoryStep], + ['Copies', copiesStep], + ['Price', priceStep], + ['Initial Phase', initialStep], + ['Ending Phase', endingStep], + ['Review', reviewStep], + ['Publish', waitStep], + [undefined, congratsStep], + ], + [AuctionCategory.Tiered]: [ + ['Category', categoryStep], + ['Number of Winners', winnersStep], + ['Tiers', tierStep], + ['Price', priceStep], + ['Initial Phase', initialStep], + ['Ending Phase', endingStep], + ['Participation NFT', participationStep], + ['Review', reviewStep], + ['Publish', waitStep], + [undefined, congratsStep], + ], + }; + + return ( + <> + + {!saving && ( +
+ + {stepsByCategory[attributes.category] + .filter(_ => !!_[0]) + .map(step => ( + + ))} + + + )} + + {stepsByCategory[attributes.category][step][1]} + {0 < step && step < stepsByCategory[attributes.category].length - 1 && ( + + )} + + + + ); +}; + +const CategoryStep = (props: { + confirm: (category: AuctionCategory) => void; +}) => { + return ( + <> + +

List an item

+

+ First time listing on Metaplex? Read our sellers' guide. +

+
+ + + + + + + + + + + + + + + + + + ); +}; + +const CopiesStep = (props: { + attributes: AuctionState; + setAttributes: (attr: AuctionState) => void; + confirm: () => void; +}) => { + let filter: ((i: SafetyDepositDraft) => boolean) | undefined; + if (props.attributes.category == AuctionCategory.Limited) { + filter = (i: SafetyDepositDraft) => !!i.masterEdition; + } else if ( + props.attributes.category == AuctionCategory.Single || + props.attributes.category == AuctionCategory.Tiered + ) { + filter = undefined; + } else if (props.attributes.category == AuctionCategory.Open) { + filter = (i: SafetyDepositDraft) => + !!( + i.masterEdition && + (i.masterEdition.info.maxSupply == undefined || + i.masterEdition.info.maxSupply == null) + ); + } + + return ( + <> + +

Select which item to sell

+

+ Select the item(s) that you want to list. +

+
+ + + { + props.setAttributes({ ...props.attributes, items }); + }} + allowMultiple={false} + > + Select NFT + + {props.attributes.category !== AuctionCategory.Open && ( + + )} + + + + + + + ); +}; + +const NumberOfWinnersStep = (props: { + attributes: AuctionState; + setAttributes: (attr: AuctionState) => void; + confirm: () => void; +}) => { + return ( + <> + +

Tiered Auction

+

Create a Tiered Auction

+
+ + + + + + + + + + ); +}; + +const TierWinners = (props: { + idx: number; + tier: Tier; + setTier: Function; + previousTo?: number; + lastTier?: Tier; +}) => { + const from = (props.previousTo || 0) + 1; + return ( + <> + + + + + +