Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@1inch/tx-confirm-data-bulder

Package Overview
Dependencies
Maintainers
4
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@1inch/tx-confirm-data-bulder

**From:**

  • 1.1.7
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
4
Weekly downloads
 
Created
Source

Builder of transaction data for confirmation screen

From:

{
    "from": "0x64741d0b9e376d75873c12e1b0cdccc26c3bcb04",
    "to": "0x1111111254fb6c44bac0bed2854e76f90643097d",
    "nonce": 194,
    "gasPrice": "0x1b7b430f2c",
    "gasLimit": "0x091d06",
    "value": "0x00",
    "data": "0x7c025200000000000000000000...00e26b9977"
}

Into:

Test coverage

StatementsBranchesFunctionsLines
StatementsBranchesFunctionsLines

Quick start

import {TxConfirmDataBuilder, Transaction} from '@1inch/tx-confirm-data-builder';

/* Implement your solution to make RPC calls to blockchain */
const rpcCaller = (method, params) => {
    return window.ethereum.request({ method, params });
}

const txUiItemsBuilder = new TxConfirmDataBuilder({
    tokens: { ... }, // Result of https://tokens.1inch.io/v1.1/1
    tokenPrices: { ... } // Result of https://token-prices.1inch.io/v1.1/1
}, rpcCaller);

const txConfig: Transaction = {
    nonce: 383,
    gasPrice: '0x1da4f97c6e',
    gasLimit: '0x011150',
    from: '0x3b608c5243732903152e38f1dab1056a4a79b980',
    to: '0x4fabb145d64652a948d72533023f6e7a623c7c53',
    value: '0x00',
    data: '0x095ea7b30000000000000000000000001111111254fb6c44bac0bed2854e76f90643097dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'
};

const { items, txType } = await txUiItemsBuilder.buildItemsForTx(txConfig);

console.log('Tx type: ', txType); // approve
console.log('Items: ', items);

Example of result:

[
    {
        "key": {
            "type": "placeholder"
        },
        "value": {
            "type": "localizable",
            "value": {
                "format": "To continue, you need to allow 1inch smart contracts to use your %%0%%. This has to be done only once for each token.",
                "args": [
                    "BUSD"
                ]
            }
        }
    },
    {
        "key": {
            "type": "token",
            "value": {
                "type": "amount",
                "token": {
                    "symbol": "BUSD",
                    "name": "Binance USD",
                    "decimals": 18,
                    "address": "0x4fabb145d64652a948d72533023f6e7a623c7c53",
                    "logoURI": "https://tokens.1inch.io/0x4fabb145d64652a948d72533023f6e7a623c7c53.png"
                }
            }
        },
        "value": {
            "type": "amount",
            "value": {
                "token": {
                    "symbol": "BUSD",
                    "name": "Binance USD",
                    "decimals": 18,
                    "address": "0x4fabb145d64652a948d72533023f6e7a623c7c53",
                    "logoURI": "https://tokens.1inch.io/0x4fabb145d64652a948d72533023f6e7a623c7c53.png"
                },
                "value": "115792089237316195423570985008687907853269984665640564039457584007913129639935",
                "sign": "0"
            }
        }
    },
    {
        "key": {
            "type": "wallet",
            "value": {
                "type": "own"
            }
        },
        "value": {
            "type": "text",
            "value": {
                "type": "address",
                "text": "0x3b608c5243732903152e38f1dab1056a4a79b980"
            }
        }
    },
    {
        "key": {
            "type": "placeholder"
        },
        "value": {
            "type": "placeholder",
            "value": {
                "type": "fee"
            }
        }
    }
]

For more examples see unit-tests

Should be implemented by consumer

  1. RPC method eth_call
  2. List of tokens
  3. List of tokens prices

1inch trade transactions and typed data

Approve:

approve:

https://etherscan.io/tx/0xbd44b75afac45ef81af448c47b40d32ac705fe2d0354b39097f5ebfd62046ffe

##NameTypeData
1_spenderaddress0x1111111254fb6c44bAC0beD2854e76F90643097d
2_valueuint256115792089237316195423570985008687907853269984665640564039457584007913129639935

Swap:

swap:

https://etherscan.io/tx/0x698156119b255c33347bf844a0245dafdc39e871f3825ae5c24cc0019be748ed

##NameTypeData
1calleraddress0x220bdA5c8994804Ac96ebe4DF184d25e5c2196D4
2desc.srcTokenaddress0xdAC17F958D2ee523a2206206994597C13D831ec7
3desc.dstTokenaddress0x853d955aCEf822Db058eb8505911ED77F175b99e
4desc.srcReceiveraddress0x220bdA5c8994804Ac96ebe4DF184d25e5c2196D4
5desc.dstReceiveraddress0x64741d0b9e376d75873C12e1B0cdccc26C3bCB04
6desc.amountuint256114445791769
7desc.minReturnAmountuint256113841200360986751251430
8desc.flagsuint2564
9desc.permitbytes0x
10databytes0x
clipperSwap:

https://etherscan.io/tx/0xd0de097ca15040e588f8528162c01f5cad29fd7ea2168b2a503bc3633a4e8a6b

##NameTypeData
1srcTokenaddress0x6B175474E89094C44Da98b954EedeAC495271d0F
2dstTokenaddress0x0000000000000000000000000000000000000000
3amountuint2562000000000000000000
4minReturnuint256424579385213342
clipperSwapWithPermit:

https://etherscan.io/tx/0x027dbf1121f509031eba135ef03a17f18bfa7195c035c73db4cfc94b55df522e

##NameTypeData
1recipientaddress0x3b608c5243732903152E38F1dAB1056A4A79b980
2srcTokenaddress0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
3dstTokenaddress0x0000000000000000000000000000000000000000
4amountuint2562000000
5minReturnuint256424703358412792
6permitbytes0x0000000000000000000000003b608c5243732903152e38f1dab1056a4a79b9800000000000000000000000001111111254fb6c44bac0bed2854e76f90643097dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000618d1d77000000000000000000000000000000000000000000000000000000000000001b8576a8af192b84d1e122d82eeddeb2fd0b006381926590f471fd23247aeeeb09010cad06bbbf7aa344d311a13ed14419a913f2015c88600dbbd579b180bf6d36
unoswap:

https://etherscan.io/tx/0x179a4f63854d6e6f5d18ec1bf31d47c4debb6a7c32a094a815e4c0eeb25f4c2d

##NameTypeData
1srcTokenaddress0x111111111117dC0aa78b770fA6A738034120C302
2amountuint2561000000000000000000
3minReturnuint256927972006385351
4poolsbytes32[]0x40000000000000003b6d034086f518368e0d49d5916e2bd9eb162e9952b7b04d
unoswapWithPermit:

https://etherscan.io/tx/0xe970c4f72e5d4a07d4fc52df338e75a082c3b4b835e40d7e4ea2df567b066de3

##NameTypeData
1srcTokenaddress0x19042021329FDdcFBea5f934FB5b2670C91F7D20
2amountuint256100000
3minReturnuint256224171088701284
4poolsbytes32[]0x40000000000000003b6d0340ec9eb7af42207a8da12a04ee4b2f2b4b9cb43bd5
5permitbytes0x0000000000000000000000003b608c5243732903152e38f1dab1056a4a79b9800000000000000000000000001111111254fb6c44bac0bed2854e76f90643097dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000618d1e72000000000000000000000000000000000000000000000000000000000000001bb71d754ebc94ea2fe86bd06f941b4607b58433d29a4bded6f42c9ea789e997cc161711ec3aa97cc6af741c0f3e804398198db0d50f701fe42889509a5e0d8fb9
uniswapV3Swap:

https://etherscan.io/tx/0xc0302a2f43cf86c04cfa8c67025da08bbc53372cc313e87ba0d32febff2f517c

##NameTypeData
1amountuint256100000000000000000
2minReturnuint256237601593079374
3poolsbytes32[]14474011154664524427946373126746238925103584872995555959354853311969479154385
uniswapV3SwapToWithPermit:

https://etherscan.io/tx/0x1b251d13fd530ddf2d4125631c71ee07b56568c1a6cf55a8e53a29a599b81e92

##NameTypeData
1recipientaddress0x3b608c5243732903152E38F1dAB1056A4A79b980
2srcTokenaddress0x111111111117dC0aa78b770fA6A738034120C302
3amountuint2569976048355247503000
4minReturnuint2563195544757858711653
5poolsbytes32[]1206715178360966712196380527409201132437477346116, 57896044618658097711785492505541897408525400718342232749193727702159444919374
6permitbytes0x0000000000000000000000003b608c5243732903152e38f1dab1056a4a79b9800000000000000000000000001111111254fb6c44bac0bed2854e76f90643097dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000006187dd53000000000000000000000000000000000000000000000000000000000000001cdae2d3851069237b24b459c7c732ce95d1ed8519fa084ab44f167f356c1310134e9f3100eee9ec3d6b3631d82367ea69af53f5a626596da45c6c441749c376d6

Permit typed data:

regular permit:
{
    "types": {
        "EIP712Domain": [
            {
                "name": "name",
                "type": "string"
            },
            {
                "name": "version",
                "type": "string"
            },
            {
                "name": "chainId",
                "type": "uint256"
            },
            {
                "name": "verifyingContract",
                "type": "address"
            }
        ],
        "Permit": [
            {
                "name": "owner",
                "type": "address"
            },
            {
                "name": "spender",
                "type": "address"
            },
            {
                "name": "value",
                "type": "uint256"
            },
            {
                "name": "nonce",
                "type": "uint256"
            },
            {
                "name": "deadline",
                "type": "uint256"
            }
        ]
    },
    "primaryType": "Permit",
    "domain": {
        "name": "1INCH Token",
        "chainId": 1,
        "verifyingContract": "0x111111111117dc0aa78b770fa6a738034120c302",
        "version": "1"
    },
    "message": {
        "deadline": 1636957129,
        "nonce": 3,
        "spender": "0x1111111254fb6c44bac0bed2854e76f90643097d",
        "owner": "0xfb3c7eb936caa12b5a884d612393969a557d4307",
        "value": "115792089237316195423570985008687907853269984665640564039457584007913129639935"
    }
}
DAI-like permit:
{
    "types": {
        "EIP712Domain": [
            {
                "name": "name",
                "type": "string"
            },
            {
                "name": "version",
                "type": "string"
            },
            {
                "name": "chainId",
                "type": "uint256"
            },
            {
                "name": "verifyingContract",
                "type": "address"
            }
        ],
        "Permit": [
            {
                "name": "holder",
                "type": "address"
            },
            {
                "name": "spender",
                "type": "address"
            },
            {
                "name": "nonce",
                "type": "uint256"
            },
            {
                "name": "expiry",
                "type": "uint256"
            },
            {
                "name": "allowed",
                "type": "bool"
            }
        ]
    },
    "primaryType": "Permit",
    "domain": {
        "name": "renBTC",
        "chainId": 1,
        "verifyingContract": "0xeb4c2781e4eba804ce9a9803c67d0893436bb27d",
        "version": "1"
    },
    "message": {
        "expiry": 1636957217,
        "nonce": 0,
        "spender": "0x1111111254fb6c44bac0bed2854e76f90643097d",
        "holder": "0xfb3c7eb936caa12b5a884d612393969a557d4307",
        "allowed": true
    }
}

Limit order typed data:

Limit order:
{
    "primaryType": "Order",
    "types": {
        "EIP712Domain": [
            {
                "name": "name",
                "type": "string"
            },
            {
                "name": "version",
                "type": "string"
            },
            {
                "name": "chainId",
                "type": "uint256"
            },
            {
                "name": "verifyingContract",
                "type": "address"
            }
        ],
        "Order": [
            {
                "name": "salt",
                "type": "uint256"
            },
            {
                "name": "makerAsset",
                "type": "address"
            },
            {
                "name": "takerAsset",
                "type": "address"
            },
            {
                "name": "makerAssetData",
                "type": "bytes"
            },
            {
                "name": "takerAssetData",
                "type": "bytes"
            },
            {
                "name": "getMakerAmount",
                "type": "bytes"
            },
            {
                "name": "getTakerAmount",
                "type": "bytes"
            },
            {
                "name": "predicate",
                "type": "bytes"
            },
            {
                "name": "permit",
                "type": "bytes"
            },
            {
                "name": "interaction",
                "type": "bytes"
            }
        ]
    },
    "domain": {
        "name": "1inch Limit Order Protocol",
        "version": "1",
        "chainId": 1,
        "verifyingContract": "0x3ef51736315f52d568d6d2cf289419b9cfffe782"
    },
    "message": {
        "salt": "1502377947330",
        "makerAsset": "0x6b175474e89094c44da98b954eedeac495271d0f",
        "takerAsset": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
        "makerAssetData": "0x23b872dd000000000000000000000000fb3c7eb936caa12b5a884d612393969a557d430700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001bc16d674ec80000",
        "takerAssetData": "0x23b872dd0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fb3c7eb936caa12b5a884d612393969a557d43070000000000000000000000000000000000000000000000000002d79883d20000",
        "getMakerAmount": "0xf4a215c30000000000000000000000000000000000000000000000001bc16d674ec800000000000000000000000000000000000000000000000000000002d79883d20000",
        "getTakerAmount": "0x296637bf0000000000000000000000000000000000000000000000001bc16d674ec800000000000000000000000000000000000000000000000000000002d79883d20000",
        "predicate": "0x961d5b1e000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000003ef51736315f52d568d6d2cf289419b9cfffe7820000000000000000000000003ef51736315f52d568d6d2cf289419b9cfffe7820000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000044cf6fc6e3000000000000000000000000fb3c7eb936caa12b5a884d612393969a557d4307000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002463592c2b000000000000000000000000000000000000000000000000000000006191f0a000000000000000000000000000000000000000000000000000000000",
        "permit": "0x",
        "interaction": "0x"
    }
}

FAQs

Package last updated on 15 Dec 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc