diff --git a/.prettierignore b/.prettierignore index 25e008b1..45e1ce2e 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,5 +1,6 @@ **/node_modules +packages/core/src/graphql.ts packages/hooks/src/graphql.ts **/dist diff --git a/package-lock.json b/package-lock.json index 6c79272e..e22c0be2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1676,6 +1676,33 @@ "node": "*" } }, + "node_modules/@ethersproject/abi": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/abi/-/abi-5.7.0.tgz", + "integrity": "sha512-351ktp42TiRcYB3H1OP8yajPeAQstMW/yCFokj/AthP9bLHzQFPlOrxOcwYEDkUAICmOHljvN4K39OMTMUa9RA==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "peer": true, + "dependencies": { + "@ethersproject/address": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/constants": "^5.7.0", + "@ethersproject/hash": "^5.7.0", + "@ethersproject/keccak256": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/strings": "^5.7.0" + } + }, "node_modules/@ethersproject/abstract-provider": { "version": "5.7.0", "resolved": "https://registry.npmjs.org/@ethersproject/abstract-provider/-/abstract-provider-5.7.0.tgz", @@ -1762,6 +1789,26 @@ "@ethersproject/bytes": "^5.7.0" } }, + "node_modules/@ethersproject/basex": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/basex/-/basex-5.7.0.tgz", + "integrity": "sha512-ywlh43GwZLv2Voc2gQVTKBoVQ1mti3d8HK5aMxsfu/nRDnMmNqaSJ3r3n85HBByT8OpoY96SXM1FogC533T4zw==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "peer": true, + "dependencies": { + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/properties": "^5.7.0" + } + }, "node_modules/@ethersproject/bignumber": { "version": "5.7.0", "resolved": "https://registry.npmjs.org/@ethersproject/bignumber/-/bignumber-5.7.0.tgz", @@ -1818,6 +1865,122 @@ "@ethersproject/bignumber": "^5.7.0" } }, + "node_modules/@ethersproject/contracts": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/contracts/-/contracts-5.7.0.tgz", + "integrity": "sha512-5GJbzEU3X+d33CdfPhcyS+z8MzsTrBGk/sc+G+59+tPa9yFkl6HQ9D6L0QMgNTA9q8dT0XKxxkyp883XsQvbbg==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "peer": true, + "dependencies": { + "@ethersproject/abi": "^5.7.0", + "@ethersproject/abstract-provider": "^5.7.0", + "@ethersproject/abstract-signer": "^5.7.0", + "@ethersproject/address": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/constants": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/transactions": "^5.7.0" + } + }, + "node_modules/@ethersproject/hash": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/hash/-/hash-5.7.0.tgz", + "integrity": "sha512-qX5WrQfnah1EFnO5zJv1v46a8HW0+E5xuBBDTwMFZLuVTx0tbU2kkx15NqdjxecrLGatQN9FGQKpb1FKdHCt+g==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "peer": true, + "dependencies": { + "@ethersproject/abstract-signer": "^5.7.0", + "@ethersproject/address": "^5.7.0", + "@ethersproject/base64": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/keccak256": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/strings": "^5.7.0" + } + }, + "node_modules/@ethersproject/hdnode": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/hdnode/-/hdnode-5.7.0.tgz", + "integrity": "sha512-OmyYo9EENBPPf4ERhR7oj6uAtUAhYGqOnIS+jE5pTXvdKBS99ikzq1E7Iv0ZQZ5V36Lqx1qZLeak0Ra16qpeOg==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "peer": true, + "dependencies": { + "@ethersproject/abstract-signer": "^5.7.0", + "@ethersproject/basex": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/pbkdf2": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/sha2": "^5.7.0", + "@ethersproject/signing-key": "^5.7.0", + "@ethersproject/strings": "^5.7.0", + "@ethersproject/transactions": "^5.7.0", + "@ethersproject/wordlists": "^5.7.0" + } + }, + "node_modules/@ethersproject/json-wallets": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/json-wallets/-/json-wallets-5.7.0.tgz", + "integrity": "sha512-8oee5Xgu6+RKgJTkvEMl2wDgSPSAQ9MB/3JYjFV9jlKvcYHUXZC+cQp0njgmxdHkYWn8s6/IqIZYm0YWCjO/0g==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "peer": true, + "dependencies": { + "@ethersproject/abstract-signer": "^5.7.0", + "@ethersproject/address": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/hdnode": "^5.7.0", + "@ethersproject/keccak256": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/pbkdf2": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/random": "^5.7.0", + "@ethersproject/strings": "^5.7.0", + "@ethersproject/transactions": "^5.7.0", + "aes-js": "3.0.0", + "scrypt-js": "3.0.1" + } + }, "node_modules/@ethersproject/keccak256": { "version": "5.7.0", "resolved": "https://registry.npmjs.org/@ethersproject/keccak256/-/keccak256-5.7.0.tgz", @@ -1870,6 +2033,26 @@ "@ethersproject/logger": "^5.7.0" } }, + "node_modules/@ethersproject/pbkdf2": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/pbkdf2/-/pbkdf2-5.7.0.tgz", + "integrity": "sha512-oR/dBRZR6GTyaofd86DehG72hY6NpAjhabkhxgr3X2FpJtJuodEl2auADWBZfhDHgVCbu3/H/Ocq2uC6dpNjjw==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "peer": true, + "dependencies": { + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/sha2": "^5.7.0" + } + }, "node_modules/@ethersproject/properties": { "version": "5.7.0", "resolved": "https://registry.npmjs.org/@ethersproject/properties/-/properties-5.7.0.tgz", @@ -1888,6 +2071,85 @@ "@ethersproject/logger": "^5.7.0" } }, + "node_modules/@ethersproject/providers": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/@ethersproject/providers/-/providers-5.7.2.tgz", + "integrity": "sha512-g34EWZ1WWAVgr4aptGlVBF8mhl3VWjv+8hoAnzStu8Ah22VHBsuGzP17eb6xDVRzw895G4W7vvx60lFFur/1Rg==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "peer": true, + "dependencies": { + "@ethersproject/abstract-provider": "^5.7.0", + "@ethersproject/abstract-signer": "^5.7.0", + "@ethersproject/address": "^5.7.0", + "@ethersproject/base64": "^5.7.0", + "@ethersproject/basex": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/constants": "^5.7.0", + "@ethersproject/hash": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/networks": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/random": "^5.7.0", + "@ethersproject/rlp": "^5.7.0", + "@ethersproject/sha2": "^5.7.0", + "@ethersproject/strings": "^5.7.0", + "@ethersproject/transactions": "^5.7.0", + "@ethersproject/web": "^5.7.0", + "bech32": "1.1.4", + "ws": "7.4.6" + } + }, + "node_modules/@ethersproject/providers/node_modules/ws": { + "version": "7.4.6", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.6.tgz", + "integrity": "sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==", + "peer": true, + "engines": { + "node": ">=8.3.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/@ethersproject/random": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/random/-/random-5.7.0.tgz", + "integrity": "sha512-19WjScqRA8IIeWclFme75VMXSBvi4e6InrUNuaR4s5pTF2qNhcGdCUwdxUVGtDDqC00sDLCO93jPQoDUH4HVmQ==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "peer": true, + "dependencies": { + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0" + } + }, "node_modules/@ethersproject/rlp": { "version": "5.7.0", "resolved": "https://registry.npmjs.org/@ethersproject/rlp/-/rlp-5.7.0.tgz", @@ -1907,6 +2169,27 @@ "@ethersproject/logger": "^5.7.0" } }, + "node_modules/@ethersproject/sha2": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/sha2/-/sha2-5.7.0.tgz", + "integrity": "sha512-gKlH42riwb3KYp0reLsFTokByAKoJdgFCwI+CCiX/k+Jm2mbNs6oOaCjYQSlI1+XBVejwH2KrmCbMAT/GnRDQw==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "peer": true, + "dependencies": { + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "hash.js": "1.1.7" + } + }, "node_modules/@ethersproject/signing-key": { "version": "5.7.0", "resolved": "https://registry.npmjs.org/@ethersproject/signing-key/-/signing-key-5.7.0.tgz", @@ -1930,6 +2213,30 @@ "hash.js": "1.1.7" } }, + "node_modules/@ethersproject/solidity": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/solidity/-/solidity-5.7.0.tgz", + "integrity": "sha512-HmabMd2Dt/raavyaGukF4XxizWKhKQ24DoLtdNbBmNKUOPqwjsKQSdV9GQtj9CBEea9DlzETlVER1gYeXXBGaA==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "peer": true, + "dependencies": { + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/keccak256": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/sha2": "^5.7.0", + "@ethersproject/strings": "^5.7.0" + } + }, "node_modules/@ethersproject/strings": { "version": "5.7.0", "resolved": "https://registry.npmjs.org/@ethersproject/strings/-/strings-5.7.0.tgz", @@ -1976,6 +2283,60 @@ "@ethersproject/signing-key": "^5.7.0" } }, + "node_modules/@ethersproject/units": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/units/-/units-5.7.0.tgz", + "integrity": "sha512-pD3xLMy3SJu9kG5xDGI7+xhTEmGXlEqXU4OfNapmfnxLVY4EMSSRp7j1k7eezutBPH7RBN/7QPnwR7hzNlEFeg==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "peer": true, + "dependencies": { + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/constants": "^5.7.0", + "@ethersproject/logger": "^5.7.0" + } + }, + "node_modules/@ethersproject/wallet": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/wallet/-/wallet-5.7.0.tgz", + "integrity": "sha512-MhmXlJXEJFBFVKrDLB4ZdDzxcBxQ3rLyCkhNqVu3CDYvR97E+8r01UgrI+TI99Le+aYm/in/0vp86guJuM7FCA==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "peer": true, + "dependencies": { + "@ethersproject/abstract-provider": "^5.7.0", + "@ethersproject/abstract-signer": "^5.7.0", + "@ethersproject/address": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/hash": "^5.7.0", + "@ethersproject/hdnode": "^5.7.0", + "@ethersproject/json-wallets": "^5.7.0", + "@ethersproject/keccak256": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/random": "^5.7.0", + "@ethersproject/signing-key": "^5.7.0", + "@ethersproject/transactions": "^5.7.0", + "@ethersproject/wordlists": "^5.7.0" + } + }, "node_modules/@ethersproject/web": { "version": "5.7.1", "resolved": "https://registry.npmjs.org/@ethersproject/web/-/web-5.7.1.tgz", @@ -1998,6 +2359,29 @@ "@ethersproject/strings": "^5.7.0" } }, + "node_modules/@ethersproject/wordlists": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/wordlists/-/wordlists-5.7.0.tgz", + "integrity": "sha512-S2TFNJNfHWVHNE6cNDjbVlZ6MgE17MIxMbMg2zv3wn+3XSJGosL1m9ZVv3GXCf/2ymSsQ+hRI5IzoMJTG6aoVA==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "peer": true, + "dependencies": { + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/hash": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/strings": "^5.7.0" + } + }, "node_modules/@gar/promisify": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/@gar/promisify/-/promisify-1.1.3.tgz", @@ -3317,6 +3701,10 @@ "npm": ">=8.0.0" } }, + "node_modules/@liteflow/core": { + "resolved": "packages/core", + "link": true + }, "node_modules/@magic-sdk/provider": { "version": "2.8.0", "resolved": "https://registry.npmjs.org/@magic-sdk/provider/-/provider-2.8.0.tgz", @@ -4890,6 +5278,12 @@ "integrity": "sha512-qQLMr+8o0WC4FZGQTcJiKBVC59JylcPSrTtk6usvmIDFUOCKegapy1VHQwRbFMOFyb/inzUVqHs+eMYKDM1YeQ==", "dev": true }, + "node_modules/aes-js": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.0.0.tgz", + "integrity": "sha512-H7wUZRn8WpTq9jocdxQ2c8x2sKo9ZVmzfRE13GiNJXfp7NcKYEdvl3vspKjXox6RIG2VtaRe4JFvxG4rqp2Zuw==", + "peer": true + }, "node_modules/agent-base": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", @@ -5250,6 +5644,12 @@ } ] }, + "node_modules/bech32": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/bech32/-/bech32-1.1.4.tgz", + "integrity": "sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ==", + "peer": true + }, "node_modules/before-after-hook": { "version": "2.2.3", "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.3.tgz", @@ -5422,7 +5822,6 @@ "version": "4.0.7", "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.7.tgz", "integrity": "sha512-kukuqc39WOHtdxtw4UScxF/WVnMFVSQVKhtx3AjZJzhd0RGZZldcrfSEbVsWWe6KNH253574cq5F+wpv0G9pJw==", - "dev": true, "hasInstallScript": true, "optional": true, "peer": true, @@ -7249,6 +7648,54 @@ "node": ">=0.10.0" } }, + "node_modules/ethers": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/ethers/-/ethers-5.7.2.tgz", + "integrity": "sha512-wswUsmWo1aOK8rR7DIKiWSw9DbLWe6x98Jrn8wcTflTVvaXhAMaB5zGAXy0GYQEQp9iO1iSHWVyARQm11zUtyg==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "peer": true, + "dependencies": { + "@ethersproject/abi": "5.7.0", + "@ethersproject/abstract-provider": "5.7.0", + "@ethersproject/abstract-signer": "5.7.0", + "@ethersproject/address": "5.7.0", + "@ethersproject/base64": "5.7.0", + "@ethersproject/basex": "5.7.0", + "@ethersproject/bignumber": "5.7.0", + "@ethersproject/bytes": "5.7.0", + "@ethersproject/constants": "5.7.0", + "@ethersproject/contracts": "5.7.0", + "@ethersproject/hash": "5.7.0", + "@ethersproject/hdnode": "5.7.0", + "@ethersproject/json-wallets": "5.7.0", + "@ethersproject/keccak256": "5.7.0", + "@ethersproject/logger": "5.7.0", + "@ethersproject/networks": "5.7.1", + "@ethersproject/pbkdf2": "5.7.0", + "@ethersproject/properties": "5.7.0", + "@ethersproject/providers": "5.7.2", + "@ethersproject/random": "5.7.0", + "@ethersproject/rlp": "5.7.0", + "@ethersproject/sha2": "5.7.0", + "@ethersproject/signing-key": "5.7.0", + "@ethersproject/solidity": "5.7.0", + "@ethersproject/strings": "5.7.0", + "@ethersproject/transactions": "5.7.0", + "@ethersproject/units": "5.7.0", + "@ethersproject/wallet": "5.7.0", + "@ethersproject/web": "5.7.1", + "@ethersproject/wordlists": "5.7.0" + } + }, "node_modules/event-target-shim": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", @@ -10817,7 +11264,6 @@ "version": "4.5.0", "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.5.0.tgz", "integrity": "sha512-2iGbaQBV+ITgCz76ZEjmhUKAKVf7xfY1sRl4UiKQspfZMH2h06SyhNsnSVy50cwkFQDGLyif6m/6uFXHkOZ6rg==", - "dev": true, "optional": true, "peer": true, "bin": { @@ -12990,6 +13436,12 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "devOptional": true }, + "node_modules/scrypt-js": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/scrypt-js/-/scrypt-js-3.0.1.tgz", + "integrity": "sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA==", + "peer": true + }, "node_modules/scuid": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/scuid/-/scuid-1.1.0.tgz", @@ -14071,7 +14523,6 @@ "version": "5.0.10", "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.10.tgz", "integrity": "sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ==", - "dev": true, "hasInstallScript": true, "optional": true, "peer": true, @@ -14608,6 +15059,24 @@ "storybook-react-context": "^0.6.0" } }, + "packages/core": { + "name": "@liteflow/core", + "version": "1.0.0", + "dependencies": { + "graphql-request": "^5.0.0", + "ts-invariant": "^0.9.4" + }, + "devDependencies": { + "@graphql-codegen/cli": "^1.21.7", + "@graphql-codegen/typescript": "^1.23.0", + "@graphql-codegen/typescript-graphql-request": "^4.5.5", + "@graphql-codegen/typescript-operations": "^1.18.4", + "@nft/api-graphql": "^1.0.0-beta.11" + }, + "peerDependencies": { + "ethers": "^5.6.1" + } + }, "packages/email-connector": { "name": "@nft/email-connector", "version": "1.0.0", @@ -14628,6 +15097,7 @@ "@ethersproject/address": "^5.5.0", "@ethersproject/bignumber": "^5.5.0", "@ethersproject/properties": "^5.5.0", + "@liteflow/core": "*", "@pinata/ipfs-gateway-tools": "1.1.6", "dayjs": "^1.11.0", "graphql-request": "^5.0.0", @@ -15893,6 +16363,23 @@ } } }, + "@ethersproject/abi": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/abi/-/abi-5.7.0.tgz", + "integrity": "sha512-351ktp42TiRcYB3H1OP8yajPeAQstMW/yCFokj/AthP9bLHzQFPlOrxOcwYEDkUAICmOHljvN4K39OMTMUa9RA==", + "peer": true, + "requires": { + "@ethersproject/address": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/constants": "^5.7.0", + "@ethersproject/hash": "^5.7.0", + "@ethersproject/keccak256": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/strings": "^5.7.0" + } + }, "@ethersproject/abstract-provider": { "version": "5.7.0", "resolved": "https://registry.npmjs.org/@ethersproject/abstract-provider/-/abstract-provider-5.7.0.tgz", @@ -15939,6 +16426,16 @@ "@ethersproject/bytes": "^5.7.0" } }, + "@ethersproject/basex": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/basex/-/basex-5.7.0.tgz", + "integrity": "sha512-ywlh43GwZLv2Voc2gQVTKBoVQ1mti3d8HK5aMxsfu/nRDnMmNqaSJ3r3n85HBByT8OpoY96SXM1FogC533T4zw==", + "peer": true, + "requires": { + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/properties": "^5.7.0" + } + }, "@ethersproject/bignumber": { "version": "5.7.0", "resolved": "https://registry.npmjs.org/@ethersproject/bignumber/-/bignumber-5.7.0.tgz", @@ -15965,6 +16462,82 @@ "@ethersproject/bignumber": "^5.7.0" } }, + "@ethersproject/contracts": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/contracts/-/contracts-5.7.0.tgz", + "integrity": "sha512-5GJbzEU3X+d33CdfPhcyS+z8MzsTrBGk/sc+G+59+tPa9yFkl6HQ9D6L0QMgNTA9q8dT0XKxxkyp883XsQvbbg==", + "peer": true, + "requires": { + "@ethersproject/abi": "^5.7.0", + "@ethersproject/abstract-provider": "^5.7.0", + "@ethersproject/abstract-signer": "^5.7.0", + "@ethersproject/address": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/constants": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/transactions": "^5.7.0" + } + }, + "@ethersproject/hash": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/hash/-/hash-5.7.0.tgz", + "integrity": "sha512-qX5WrQfnah1EFnO5zJv1v46a8HW0+E5xuBBDTwMFZLuVTx0tbU2kkx15NqdjxecrLGatQN9FGQKpb1FKdHCt+g==", + "peer": true, + "requires": { + "@ethersproject/abstract-signer": "^5.7.0", + "@ethersproject/address": "^5.7.0", + "@ethersproject/base64": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/keccak256": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/strings": "^5.7.0" + } + }, + "@ethersproject/hdnode": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/hdnode/-/hdnode-5.7.0.tgz", + "integrity": "sha512-OmyYo9EENBPPf4ERhR7oj6uAtUAhYGqOnIS+jE5pTXvdKBS99ikzq1E7Iv0ZQZ5V36Lqx1qZLeak0Ra16qpeOg==", + "peer": true, + "requires": { + "@ethersproject/abstract-signer": "^5.7.0", + "@ethersproject/basex": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/pbkdf2": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/sha2": "^5.7.0", + "@ethersproject/signing-key": "^5.7.0", + "@ethersproject/strings": "^5.7.0", + "@ethersproject/transactions": "^5.7.0", + "@ethersproject/wordlists": "^5.7.0" + } + }, + "@ethersproject/json-wallets": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/json-wallets/-/json-wallets-5.7.0.tgz", + "integrity": "sha512-8oee5Xgu6+RKgJTkvEMl2wDgSPSAQ9MB/3JYjFV9jlKvcYHUXZC+cQp0njgmxdHkYWn8s6/IqIZYm0YWCjO/0g==", + "peer": true, + "requires": { + "@ethersproject/abstract-signer": "^5.7.0", + "@ethersproject/address": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/hdnode": "^5.7.0", + "@ethersproject/keccak256": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/pbkdf2": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/random": "^5.7.0", + "@ethersproject/strings": "^5.7.0", + "@ethersproject/transactions": "^5.7.0", + "aes-js": "3.0.0", + "scrypt-js": "3.0.1" + } + }, "@ethersproject/keccak256": { "version": "5.7.0", "resolved": "https://registry.npmjs.org/@ethersproject/keccak256/-/keccak256-5.7.0.tgz", @@ -15987,6 +16560,16 @@ "@ethersproject/logger": "^5.7.0" } }, + "@ethersproject/pbkdf2": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/pbkdf2/-/pbkdf2-5.7.0.tgz", + "integrity": "sha512-oR/dBRZR6GTyaofd86DehG72hY6NpAjhabkhxgr3X2FpJtJuodEl2auADWBZfhDHgVCbu3/H/Ocq2uC6dpNjjw==", + "peer": true, + "requires": { + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/sha2": "^5.7.0" + } + }, "@ethersproject/properties": { "version": "5.7.0", "resolved": "https://registry.npmjs.org/@ethersproject/properties/-/properties-5.7.0.tgz", @@ -15995,6 +16578,53 @@ "@ethersproject/logger": "^5.7.0" } }, + "@ethersproject/providers": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/@ethersproject/providers/-/providers-5.7.2.tgz", + "integrity": "sha512-g34EWZ1WWAVgr4aptGlVBF8mhl3VWjv+8hoAnzStu8Ah22VHBsuGzP17eb6xDVRzw895G4W7vvx60lFFur/1Rg==", + "peer": true, + "requires": { + "@ethersproject/abstract-provider": "^5.7.0", + "@ethersproject/abstract-signer": "^5.7.0", + "@ethersproject/address": "^5.7.0", + "@ethersproject/base64": "^5.7.0", + "@ethersproject/basex": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/constants": "^5.7.0", + "@ethersproject/hash": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/networks": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/random": "^5.7.0", + "@ethersproject/rlp": "^5.7.0", + "@ethersproject/sha2": "^5.7.0", + "@ethersproject/strings": "^5.7.0", + "@ethersproject/transactions": "^5.7.0", + "@ethersproject/web": "^5.7.0", + "bech32": "1.1.4", + "ws": "7.4.6" + }, + "dependencies": { + "ws": { + "version": "7.4.6", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.6.tgz", + "integrity": "sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==", + "peer": true, + "requires": {} + } + } + }, + "@ethersproject/random": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/random/-/random-5.7.0.tgz", + "integrity": "sha512-19WjScqRA8IIeWclFme75VMXSBvi4e6InrUNuaR4s5pTF2qNhcGdCUwdxUVGtDDqC00sDLCO93jPQoDUH4HVmQ==", + "peer": true, + "requires": { + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0" + } + }, "@ethersproject/rlp": { "version": "5.7.0", "resolved": "https://registry.npmjs.org/@ethersproject/rlp/-/rlp-5.7.0.tgz", @@ -16004,6 +16634,17 @@ "@ethersproject/logger": "^5.7.0" } }, + "@ethersproject/sha2": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/sha2/-/sha2-5.7.0.tgz", + "integrity": "sha512-gKlH42riwb3KYp0reLsFTokByAKoJdgFCwI+CCiX/k+Jm2mbNs6oOaCjYQSlI1+XBVejwH2KrmCbMAT/GnRDQw==", + "peer": true, + "requires": { + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "hash.js": "1.1.7" + } + }, "@ethersproject/signing-key": { "version": "5.7.0", "resolved": "https://registry.npmjs.org/@ethersproject/signing-key/-/signing-key-5.7.0.tgz", @@ -16017,6 +16658,20 @@ "hash.js": "1.1.7" } }, + "@ethersproject/solidity": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/solidity/-/solidity-5.7.0.tgz", + "integrity": "sha512-HmabMd2Dt/raavyaGukF4XxizWKhKQ24DoLtdNbBmNKUOPqwjsKQSdV9GQtj9CBEea9DlzETlVER1gYeXXBGaA==", + "peer": true, + "requires": { + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/keccak256": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/sha2": "^5.7.0", + "@ethersproject/strings": "^5.7.0" + } + }, "@ethersproject/strings": { "version": "5.7.0", "resolved": "https://registry.npmjs.org/@ethersproject/strings/-/strings-5.7.0.tgz", @@ -16043,6 +16698,40 @@ "@ethersproject/signing-key": "^5.7.0" } }, + "@ethersproject/units": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/units/-/units-5.7.0.tgz", + "integrity": "sha512-pD3xLMy3SJu9kG5xDGI7+xhTEmGXlEqXU4OfNapmfnxLVY4EMSSRp7j1k7eezutBPH7RBN/7QPnwR7hzNlEFeg==", + "peer": true, + "requires": { + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/constants": "^5.7.0", + "@ethersproject/logger": "^5.7.0" + } + }, + "@ethersproject/wallet": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/wallet/-/wallet-5.7.0.tgz", + "integrity": "sha512-MhmXlJXEJFBFVKrDLB4ZdDzxcBxQ3rLyCkhNqVu3CDYvR97E+8r01UgrI+TI99Le+aYm/in/0vp86guJuM7FCA==", + "peer": true, + "requires": { + "@ethersproject/abstract-provider": "^5.7.0", + "@ethersproject/abstract-signer": "^5.7.0", + "@ethersproject/address": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/hash": "^5.7.0", + "@ethersproject/hdnode": "^5.7.0", + "@ethersproject/json-wallets": "^5.7.0", + "@ethersproject/keccak256": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/random": "^5.7.0", + "@ethersproject/signing-key": "^5.7.0", + "@ethersproject/transactions": "^5.7.0", + "@ethersproject/wordlists": "^5.7.0" + } + }, "@ethersproject/web": { "version": "5.7.1", "resolved": "https://registry.npmjs.org/@ethersproject/web/-/web-5.7.1.tgz", @@ -16055,6 +16744,19 @@ "@ethersproject/strings": "^5.7.0" } }, + "@ethersproject/wordlists": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/wordlists/-/wordlists-5.7.0.tgz", + "integrity": "sha512-S2TFNJNfHWVHNE6cNDjbVlZ6MgE17MIxMbMg2zv3wn+3XSJGosL1m9ZVv3GXCf/2ymSsQ+hRI5IzoMJTG6aoVA==", + "peer": true, + "requires": { + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/hash": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/strings": "^5.7.0" + } + }, "@gar/promisify": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/@gar/promisify/-/promisify-1.1.3.tgz", @@ -17215,6 +17917,18 @@ "write-json-file": "^4.3.0" } }, + "@liteflow/core": { + "version": "file:packages/core", + "requires": { + "@graphql-codegen/cli": "^1.21.7", + "@graphql-codegen/typescript": "^1.23.0", + "@graphql-codegen/typescript-graphql-request": "^4.5.5", + "@graphql-codegen/typescript-operations": "^1.18.4", + "@nft/api-graphql": "^1.0.0-beta.11", + "graphql-request": "^5.0.0", + "ts-invariant": "^0.9.4" + } + }, "@magic-sdk/provider": { "version": "2.8.0", "resolved": "https://registry.npmjs.org/@magic-sdk/provider/-/provider-2.8.0.tgz", @@ -17269,6 +17983,7 @@ "@graphql-codegen/typescript": "^1.23.0", "@graphql-codegen/typescript-graphql-request": "^4.5.5", "@graphql-codegen/typescript-operations": "^1.18.4", + "@liteflow/core": "*", "@nft/api-graphql": "^1.0.0-beta.15.1", "@pinata/ipfs-gateway-tools": "1.1.6", "@types/react": "^17.0.51", @@ -18434,6 +19149,12 @@ "integrity": "sha512-qQLMr+8o0WC4FZGQTcJiKBVC59JylcPSrTtk6usvmIDFUOCKegapy1VHQwRbFMOFyb/inzUVqHs+eMYKDM1YeQ==", "dev": true }, + "aes-js": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.0.0.tgz", + "integrity": "sha512-H7wUZRn8WpTq9jocdxQ2c8x2sKo9ZVmzfRE13GiNJXfp7NcKYEdvl3vspKjXox6RIG2VtaRe4JFvxG4rqp2Zuw==", + "peer": true + }, "agent-base": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", @@ -18697,6 +19418,12 @@ "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", "dev": true }, + "bech32": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/bech32/-/bech32-1.1.4.tgz", + "integrity": "sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ==", + "peer": true + }, "before-after-hook": { "version": "2.2.3", "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.3.tgz", @@ -18826,7 +19553,6 @@ "version": "4.0.7", "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.7.tgz", "integrity": "sha512-kukuqc39WOHtdxtw4UScxF/WVnMFVSQVKhtx3AjZJzhd0RGZZldcrfSEbVsWWe6KNH253574cq5F+wpv0G9pJw==", - "dev": true, "optional": true, "peer": true, "requires": { @@ -20259,6 +20985,44 @@ "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", "dev": true }, + "ethers": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/ethers/-/ethers-5.7.2.tgz", + "integrity": "sha512-wswUsmWo1aOK8rR7DIKiWSw9DbLWe6x98Jrn8wcTflTVvaXhAMaB5zGAXy0GYQEQp9iO1iSHWVyARQm11zUtyg==", + "peer": true, + "requires": { + "@ethersproject/abi": "5.7.0", + "@ethersproject/abstract-provider": "5.7.0", + "@ethersproject/abstract-signer": "5.7.0", + "@ethersproject/address": "5.7.0", + "@ethersproject/base64": "5.7.0", + "@ethersproject/basex": "5.7.0", + "@ethersproject/bignumber": "5.7.0", + "@ethersproject/bytes": "5.7.0", + "@ethersproject/constants": "5.7.0", + "@ethersproject/contracts": "5.7.0", + "@ethersproject/hash": "5.7.0", + "@ethersproject/hdnode": "5.7.0", + "@ethersproject/json-wallets": "5.7.0", + "@ethersproject/keccak256": "5.7.0", + "@ethersproject/logger": "5.7.0", + "@ethersproject/networks": "5.7.1", + "@ethersproject/pbkdf2": "5.7.0", + "@ethersproject/properties": "5.7.0", + "@ethersproject/providers": "5.7.2", + "@ethersproject/random": "5.7.0", + "@ethersproject/rlp": "5.7.0", + "@ethersproject/sha2": "5.7.0", + "@ethersproject/signing-key": "5.7.0", + "@ethersproject/solidity": "5.7.0", + "@ethersproject/strings": "5.7.0", + "@ethersproject/transactions": "5.7.0", + "@ethersproject/units": "5.7.0", + "@ethersproject/wallet": "5.7.0", + "@ethersproject/web": "5.7.1", + "@ethersproject/wordlists": "5.7.0" + } + }, "event-target-shim": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", @@ -23148,7 +23912,6 @@ "version": "4.5.0", "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.5.0.tgz", "integrity": "sha512-2iGbaQBV+ITgCz76ZEjmhUKAKVf7xfY1sRl4UiKQspfZMH2h06SyhNsnSVy50cwkFQDGLyif6m/6uFXHkOZ6rg==", - "dev": true, "optional": true, "peer": true }, @@ -24730,6 +25493,12 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "devOptional": true }, + "scrypt-js": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/scrypt-js/-/scrypt-js-3.0.1.tgz", + "integrity": "sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA==", + "peer": true + }, "scuid": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/scuid/-/scuid-1.1.0.tgz", @@ -25589,7 +26358,6 @@ "version": "5.0.10", "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.10.tgz", "integrity": "sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ==", - "dev": true, "optional": true, "peer": true, "requires": { diff --git a/packages/core/.eslintrc.json b/packages/core/.eslintrc.json new file mode 100644 index 00000000..60e75cb6 --- /dev/null +++ b/packages/core/.eslintrc.json @@ -0,0 +1,6 @@ +{ + "extends": ["../../.eslintrc.js"], + "rules": { + "@typescript-eslint/consistent-type-imports": "error" + } +} diff --git a/packages/core/.gitignore b/packages/core/.gitignore new file mode 100644 index 00000000..fb4dd112 --- /dev/null +++ b/packages/core/.gitignore @@ -0,0 +1,2 @@ +/src/graphql.ts +dist \ No newline at end of file diff --git a/packages/core/.npmignore b/packages/core/.npmignore new file mode 100644 index 00000000..53a1936e --- /dev/null +++ b/packages/core/.npmignore @@ -0,0 +1,6 @@ +.eslintrc.js +.gitignore +node_modules +tsconfig.json +src +codegen.yml \ No newline at end of file diff --git a/packages/core/README.md b/packages/core/README.md new file mode 100644 index 00000000..1333ed77 --- /dev/null +++ b/packages/core/README.md @@ -0,0 +1 @@ +TODO diff --git a/packages/core/codegen.yml b/packages/core/codegen.yml new file mode 100644 index 00000000..c58b8bf0 --- /dev/null +++ b/packages/core/codegen.yml @@ -0,0 +1,23 @@ +schema: '../../node_modules/@nft/api-graphql/schema.graphql' +documents: + - './fragments/*.graphql' + - './mutations/*.graphql' +generates: + src/graphql.ts: + plugins: + - 'typescript' + - 'typescript-operations' + - 'typescript-graphql-request' + config: + enumsAsTypes: true +config: + scalars: + URI: 'string' + UUID: './types#UUID' + Datetime: 'string' + Cursor: 'string' + JSON: 'unknown' + Uint256: './types#Uint256' + Address: './types#Address' + TransactionHash: './types#TransactionHash' + BigFloat: 'string' diff --git a/packages/core/fragments/transaction.graphql b/packages/core/fragments/transaction.graphql new file mode 100644 index 00000000..4c4ff02e --- /dev/null +++ b/packages/core/fragments/transaction.graphql @@ -0,0 +1,7 @@ +fragment Transaction on Transaction { + to + from + data + gasPrice + value +} diff --git a/packages/core/mutations/createCollectionApprovalTransaction.graphql b/packages/core/mutations/createCollectionApprovalTransaction.graphql new file mode 100644 index 00000000..20bf2670 --- /dev/null +++ b/packages/core/mutations/createCollectionApprovalTransaction.graphql @@ -0,0 +1,15 @@ +mutation CreateCollectionApprovalTransaction( + $accountAddress: Address! + $chainId: Int! + $collectionAddress: String! +) { + createCollectionApprovalTransaction( + accountAddress: $accountAddress + chainId: $chainId + collectionAddress: $collectionAddress + ) { + transaction { + ...Transaction + } + } +} diff --git a/packages/core/mutations/createCurrencyApprovalTransaction.graphql b/packages/core/mutations/createCurrencyApprovalTransaction.graphql new file mode 100644 index 00000000..84561e35 --- /dev/null +++ b/packages/core/mutations/createCurrencyApprovalTransaction.graphql @@ -0,0 +1,15 @@ +mutation CreateCurrencyApprovalTransaction( + $accountAddress: Address! + $amount: Uint256! + $currencyId: String! +) { + createCurrencyApprovalTransaction( + accountAddress: $accountAddress + amount: $amount + currencyId: $currencyId + ) { + transaction { + ...Transaction + } + } +} diff --git a/packages/core/mutations/createOffer.graphql b/packages/core/mutations/createOffer.graphql new file mode 100644 index 00000000..453359bc --- /dev/null +++ b/packages/core/mutations/createOffer.graphql @@ -0,0 +1,19 @@ +mutation CreateOffer( + $offer: OfferInputBis! + $timestamp: Int! + $salt: String! + $signature: String! +) { + createOffer( + input: { + offer: $offer + timestamp: $timestamp + salt: $salt + signature: $signature + } + ) { + offer { + id + } + } +} diff --git a/packages/core/mutations/createOfferSignature.graphql b/packages/core/mutations/createOfferSignature.graphql new file mode 100644 index 00000000..c720b142 --- /dev/null +++ b/packages/core/mutations/createOfferSignature.graphql @@ -0,0 +1,7 @@ +mutation CreateOfferSignature($offer: OfferInputBis!) { + createOfferSignature(input: { offer: $offer }) { + eip712Data + timestamp + salt + } +} diff --git a/packages/core/package.json b/packages/core/package.json new file mode 100644 index 00000000..1745f39f --- /dev/null +++ b/packages/core/package.json @@ -0,0 +1,29 @@ +{ + "name": "@liteflow/core", + "version": "1.0.0", + "main": "./dist/index.js", + "typings": "./dist/index.d.ts", + "scripts": { + "clean": "rimraf node_modules/.cache dist tsconfig.tsbuildinfo", + "prepack": "npm run build", + "prebuild": "npm run graphql-codegen", + "build": "tsc --build", + "watch": "tsc --watch", + "graphql-codegen": "graphql-codegen --overwrite", + "test": "jest" + }, + "dependencies": { + "graphql-request": "^5.0.0", + "ts-invariant": "^0.9.4" + }, + "peerDependencies": { + "ethers": "^5.6.1" + }, + "devDependencies": { + "@graphql-codegen/cli": "^1.21.7", + "@graphql-codegen/typescript": "^1.23.0", + "@graphql-codegen/typescript-graphql-request": "^4.5.5", + "@graphql-codegen/typescript-operations": "^1.18.4", + "@nft/api-graphql": "^1.0.0-beta.11" + } +} diff --git a/packages/core/src/client.ts b/packages/core/src/client.ts new file mode 100644 index 00000000..6504826e --- /dev/null +++ b/packages/core/src/client.ts @@ -0,0 +1,15 @@ +import { GraphQLClient } from 'graphql-request' +import type { PatchedRequestInit } from 'graphql-request/dist/types' +import { Exchange } from './exchange' +import type { Sdk } from './graphql' +import { getSdk } from './graphql' + +export class Client { + private readonly sdk: Sdk + public readonly exchange: Exchange + + constructor(endpoint: URL, option: PatchedRequestInit = {}) { + this.sdk = getSdk(new GraphQLClient(endpoint.toString(), option)) + this.exchange = new Exchange(this.sdk) + } +} diff --git a/packages/core/src/exchange/approveCollection.ts b/packages/core/src/exchange/approveCollection.ts new file mode 100644 index 00000000..fa55e42b --- /dev/null +++ b/packages/core/src/exchange/approveCollection.ts @@ -0,0 +1,31 @@ +import type { TransactionResponse } from '@ethersproject/abstract-provider' +import type { Signer } from 'ethers' +import type { Sdk } from '../graphql' +import type { Address, ChainId } from '../types' +import { toAddress } from '../utils/convert' +import { sendTransaction } from '../utils/transaction' + +type CollectionApproval = { + chain: ChainId + collection: Address +} + +export async function approveCollection( + sdk: Sdk, + { chain, collection }: CollectionApproval, + signer: Signer, +): Promise { + const address = await signer.getAddress() + + const { + createCollectionApprovalTransaction: { transaction }, + } = await sdk.CreateCollectionApprovalTransaction({ + accountAddress: toAddress(address), + chainId: chain, + collectionAddress: toAddress(collection), + }) + + if (!transaction) return null + + return sendTransaction(signer, transaction) +} diff --git a/packages/core/src/exchange/approveCurrency.ts b/packages/core/src/exchange/approveCurrency.ts new file mode 100644 index 00000000..bb99cd99 --- /dev/null +++ b/packages/core/src/exchange/approveCurrency.ts @@ -0,0 +1,32 @@ +import type { TransactionResponse } from '@ethersproject/abstract-provider' +import type { Signer } from 'ethers' +import type { Sdk } from '../graphql' +import type { Address, ChainId, Uint256 } from '../types' +import { toAddress, toCurrencyId } from '../utils/convert' +import { sendTransaction } from '../utils/transaction' + +type CurrencyApproval = { + chain: ChainId + currency: Address + amount: Uint256 +} + +export async function approveCurrency( + sdk: Sdk, + { chain, currency, amount }: CurrencyApproval, + signer: Signer, +): Promise { + const address = await signer.getAddress() + + const { + createCurrencyApprovalTransaction: { transaction }, + } = await sdk.CreateCurrencyApprovalTransaction({ + accountAddress: toAddress(address), + currencyId: toCurrencyId(chain, toAddress(currency)), + amount: amount.toString(), + }) + + if (!transaction) return null + + return sendTransaction(signer, transaction) +} diff --git a/packages/core/src/exchange/index.ts b/packages/core/src/exchange/index.ts new file mode 100644 index 00000000..4ff40be8 --- /dev/null +++ b/packages/core/src/exchange/index.ts @@ -0,0 +1,31 @@ +import type { Signer } from 'ethers' +import type { Sdk } from '../graphql' +import type { UUID } from '../types' +import type { Listing, State as ListTokenState } from './listToken' +import { listToken } from './listToken' +import type { Bid, State as PlaceBidState } from './placeBid' +import { placeBid } from './placeBid' + +export class Exchange { + private readonly sdk: Sdk + + constructor(sdk: Sdk) { + this.sdk = sdk + } + + async placeBid( + bid: Bid, + signer: Signer, + onProgress?: (state: PlaceBidState) => void, + ): Promise { + return placeBid(this.sdk, bid, signer, onProgress) + } + + async listToken( + listing: Listing, + signer: Signer, + onProgress?: (state: ListTokenState) => void, + ): Promise { + return listToken(this.sdk, listing, signer, onProgress) + } +} diff --git a/packages/core/src/exchange/listToken.ts b/packages/core/src/exchange/listToken.ts new file mode 100644 index 00000000..4bde567f --- /dev/null +++ b/packages/core/src/exchange/listToken.ts @@ -0,0 +1,88 @@ +import type { Signer } from 'ethers' +import { BigNumber } from 'ethers' +import type { OfferInputBis, Sdk } from '../graphql' +import type { + Address, + ChainId, + EIP712Data, + IState, + TransactionHash, + Uint256, + UUID, +} from '../types' +import { + toAddress, + toAssetId, + toCurrencyId, + toTransactionHash, +} from '../utils/convert' +import { signEIP712 } from '../utils/signature' +import { approveCollection } from './approveCollection' + +export type State = + | IState<'APPROVAL_SIGNATURE', {}> + | IState<'APPROVAL_PENDING', { txHash: TransactionHash }> + | IState<'OFFER_SIGNATURE', { signature: EIP712Data }> + +export type Listing = { + chain: ChainId + collection: Address + token: string + unitPrice: { + amount: Uint256 + currency: Address | null + } + quantity?: Uint256 + taker?: Address + expiredAt?: Date +} + +export async function listToken( + sdk: Sdk, + { chain, collection, token, unitPrice, quantity, taker, expiredAt }: Listing, + signer: Signer, + onProgress?: (state: State) => void, +): Promise { + const address = await signer.getAddress() + + const offer: OfferInputBis = { + type: 'SALE', + makerAddress: toAddress(address), + assetId: toAssetId(chain, collection, token), + currencyId: toCurrencyId(chain, unitPrice.currency), + unitPrice: BigNumber.from(unitPrice.amount).toString(), + quantity: BigNumber.from(quantity || '1').toString(), + takerAddress: taker, + expiredAt: expiredAt ? expiredAt.toISOString() : undefined, + } + + onProgress?.({ type: 'APPROVAL_SIGNATURE', payload: {} }) + const tx = await approveCollection(sdk, { chain, collection }, signer) + if (tx) { + onProgress?.({ + type: 'APPROVAL_PENDING', + payload: { txHash: toTransactionHash(tx.hash) }, + }) + await tx.wait() + } + + const { + createOfferSignature: { eip712Data, salt, timestamp }, + } = await sdk.CreateOfferSignature({ offer }) + const eip712 = eip712Data as EIP712Data + onProgress?.({ type: 'OFFER_SIGNATURE', payload: { signature: eip712 } }) + + const signature = await signEIP712(signer, eip712) + + const { + createOffer: { + offer: { id }, + }, + } = await sdk.CreateOffer({ + offer, + signature, + salt, + timestamp, + }) + return id +} diff --git a/packages/core/src/exchange/placeBid.ts b/packages/core/src/exchange/placeBid.ts new file mode 100644 index 00000000..84d1b355 --- /dev/null +++ b/packages/core/src/exchange/placeBid.ts @@ -0,0 +1,109 @@ +import type { Signer } from 'ethers' +import { BigNumber } from 'ethers' +import type { OfferInputBis, Sdk } from '../graphql' +import type { + Address, + ChainId, + EIP712Data, + IState, + TransactionHash, + Uint256, + UUID, +} from '../types' +import { + toAddress, + toAssetId, + toCurrencyId, + toTransactionHash, +} from '../utils/convert' +import { signEIP712 } from '../utils/signature' +import { approveCurrency } from './approveCurrency' + +export type State = + | IState<'APPROVAL_SIGNATURE', {}> + | IState<'APPROVAL_PENDING', { txHash: TransactionHash }> + | IState<'OFFER_SIGNATURE', { signature: EIP712Data }> + +export type Bid = { + chain: ChainId + collection: Address + token: string + unitPrice: { + amount: Uint256 + currency: Address + } + quantity?: Uint256 + taker?: Address + expiredAt?: Date + auctionId?: UUID +} + +export async function placeBid( + sdk: Sdk, + { + chain, + collection, + token, + unitPrice, + quantity, + taker, + expiredAt, + auctionId, + }: Bid, + signer: Signer, + onProgress?: (state: State) => void, +): Promise { + const address = await signer.getAddress() + + const offer: OfferInputBis = { + type: 'BUY', + makerAddress: toAddress(address), + assetId: toAssetId(chain, collection, token), + currencyId: toCurrencyId(chain, unitPrice.currency), + unitPrice: BigNumber.from(unitPrice.amount).toString(), + quantity: BigNumber.from(quantity || '1').toString(), + takerAddress: taker, + expiredAt: expiredAt ? expiredAt.toISOString() : null, + auctionId: auctionId, + } + + onProgress?.({ type: 'APPROVAL_SIGNATURE', payload: {} }) + const tx = await approveCurrency( + sdk, + { + chain, + currency: unitPrice.currency, + amount: BigNumber.from(unitPrice.amount) + .mul(BigNumber.from(quantity || '1')) + .toString(), + }, + signer, + ) + if (tx) { + onProgress?.({ + type: 'APPROVAL_PENDING', + payload: { txHash: toTransactionHash(tx.hash) }, + }) + await tx.wait() + } + + const { + createOfferSignature: { eip712Data, salt, timestamp }, + } = await sdk.CreateOfferSignature({ offer }) + const eip712 = eip712Data as EIP712Data + onProgress?.({ type: 'OFFER_SIGNATURE', payload: { signature: eip712 } }) + + const signature = await signEIP712(signer, eip712) + + const { + createOffer: { + offer: { id }, + }, + } = await sdk.CreateOffer({ + offer, + signature, + salt, + timestamp, + }) + return id +} diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts new file mode 100644 index 00000000..7f4f86c2 --- /dev/null +++ b/packages/core/src/index.ts @@ -0,0 +1,3 @@ +export { Client } from './client' +export * from './types' +export * from './utils/convert' diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts new file mode 100644 index 00000000..2c1e9ac1 --- /dev/null +++ b/packages/core/src/types.ts @@ -0,0 +1,24 @@ +import type { BigNumberish, TypedDataDomain, TypedDataField } from 'ethers' +import type { PatchedRequestInit } from 'graphql-request/dist/types' + +export type ClientOption = { + endpoint: URL + options?: PatchedRequestInit +} + +export type EIP712Data = { + domain: TypedDataDomain + types: Record> + message: Record +} + +export type TransactionHash = `0x${string}` +export type ChainId = number +export type Address = `0x${string}` +export type UUID = string +export type Uint256 = BigNumberish + +export interface IState { + type: Type + payload: Payload +} diff --git a/packages/core/src/utils/convert.ts b/packages/core/src/utils/convert.ts new file mode 100644 index 00000000..cc2571c7 --- /dev/null +++ b/packages/core/src/utils/convert.ts @@ -0,0 +1,28 @@ +import type { Address, ChainId, TransactionHash } from '../types' + +export function toAddress(address: string): Address { + return `0x${address.toLowerCase().replace(/^0x/, '')}` +} + +export function toTransactionHash(hash: string): TransactionHash { + return `0x${hash.toLowerCase().replace(/^0x/, '')}` +} + +export function toId(keys: (string | undefined | null)[]): string { + return keys.filter(Boolean).join('-') +} + +export function toAssetId( + chainId: ChainId, + address: Address, + token: string, +): string { + return toId([chainId.toString(), address, token]) +} + +export function toCurrencyId( + chainId: ChainId, + address: Address | null, +): string { + return toId([chainId.toString(), address]) +} diff --git a/packages/core/src/utils/signature.ts b/packages/core/src/utils/signature.ts new file mode 100644 index 00000000..e20d6737 --- /dev/null +++ b/packages/core/src/utils/signature.ts @@ -0,0 +1,21 @@ +import type { TypedDataSigner } from '@ethersproject/abstract-signer' +import type { Signer } from 'ethers' +import invariant from 'ts-invariant' +import type { EIP712Data } from '../types' + +export function signEIP712( + signer: Signer, + eip712Data: EIP712Data, +): Promise { + const { domain, types, message } = eip712Data + delete types.EIP712Domain // Hack: remove primary type from types to allow ethers detect the main type "Order" (aka: primaryType) + invariant( + (signer as unknown as TypedDataSigner)._signTypedData, + 'Signer does not support EIP712', + ) + return (signer as unknown as TypedDataSigner)._signTypedData( + domain, + types, + message, + ) +} diff --git a/packages/core/src/utils/transaction.ts b/packages/core/src/utils/transaction.ts new file mode 100644 index 00000000..360793cc --- /dev/null +++ b/packages/core/src/utils/transaction.ts @@ -0,0 +1,20 @@ +import type { TransactionResponse } from '@ethersproject/abstract-provider' +import type { Signer } from 'ethers' +import { BigNumber } from 'ethers' +import type { Transaction } from '../graphql' + +export async function sendTransaction( + signer: Signer, + transaction: Transaction, +): Promise { + const tx = await signer.sendTransaction({ + to: transaction.to || undefined, + from: transaction.from || undefined, + data: transaction.data || undefined, + value: transaction.value ? BigNumber.from(transaction.value) : undefined, + gasPrice: transaction.gasPrice + ? BigNumber.from(transaction.gasPrice) + : undefined, + }) + return tx +} diff --git a/packages/core/tsconfig.json b/packages/core/tsconfig.json new file mode 100644 index 00000000..41806822 --- /dev/null +++ b/packages/core/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "./dist", + "rootDir": "./src" + }, + "include": ["src"], + "exclude": ["node_modules", "dist"] +} diff --git a/packages/hooks/package.json b/packages/hooks/package.json index 32efea64..5bf3df29 100644 --- a/packages/hooks/package.json +++ b/packages/hooks/package.json @@ -17,6 +17,7 @@ "@ethersproject/address": "^5.5.0", "@ethersproject/bignumber": "^5.5.0", "@ethersproject/properties": "^5.5.0", + "@liteflow/core": "*", "@pinata/ipfs-gateway-tools": "1.1.6", "dayjs": "^1.11.0", "graphql-request": "^5.0.0", diff --git a/packages/hooks/src/context.tsx b/packages/hooks/src/context.tsx index 9a99b60f..33b17d38 100644 --- a/packages/hooks/src/context.tsx +++ b/packages/hooks/src/context.tsx @@ -1,3 +1,4 @@ +import { Client } from '@liteflow/core' import { gql, GraphQLClient } from 'graphql-request' import decode, { JwtPayload } from 'jwt-decode' import React, { @@ -28,6 +29,7 @@ export type LiteflowContext = { resetAuthenticationToken: () => void currentAddress: string | null sdk: Sdk + client: Client } export type LiteflowProviderProps = { @@ -43,6 +45,7 @@ export const LiteflowContext = createContext({ }, currentAddress: null, sdk: {} as Sdk, + client: {} as Client, }) export function LiteflowProvider({ @@ -51,6 +54,15 @@ export function LiteflowProvider({ }: PropsWithChildren): JSX.Element { const [authenticationToken, setAuthenticationToken] = useState() const client = useMemo(() => new GraphQLClient(endpoint), [endpoint]) + const coreClient = useMemo( + () => + new Client(new URL(endpoint), { + headers: authenticationToken + ? { Authorization: `Bearer ${authenticationToken}` } + : undefined, + }), + [endpoint, authenticationToken], + ) const sdk = useMemo(() => getSdk(client), [client]) const currentAddress = useMemo(() => { if (!authenticationToken) return null @@ -80,6 +92,7 @@ export function LiteflowProvider({ setAuthenticationToken, currentAddress, sdk, + client: coreClient, }} > {children} diff --git a/packages/hooks/src/useCreateOffer.ts b/packages/hooks/src/useCreateOffer.ts index 40e0eb94..7e77a0e6 100644 --- a/packages/hooks/src/useCreateOffer.ts +++ b/packages/hooks/src/useCreateOffer.ts @@ -1,53 +1,23 @@ import { Signer, TypedDataSigner } from '@ethersproject/abstract-signer' import { BigNumber } from '@ethersproject/bignumber' +import { toAddress, TransactionHash } from '@liteflow/core' import { gql } from 'graphql-request' -import { useCallback, useContext, useEffect, useState } from 'react' +import { useCallback, useContext, useState } from 'react' import invariant from 'ts-invariant' import { LiteflowContext } from './context' import { ErrorMessages } from './errorMessages' import { OfferType } from './graphql' -import useApproveCollection, { - ApproveCollectionStep, -} from './useApproveCollection' -import useApproveCurrency, { ApproveCurrencyStep } from './useApproveCurrency' gql` - query FetchAssetForOffer($assetId: String!) { + query FetchAssetForOffer($assetId: String!, $currencyId: String!) { asset(id: $assetId) { chainId collectionAddress + tokenId } - } -` - -gql` - mutation CreateOfferSignature($offer: OfferInputBis!) { - createOfferSignature(input: { offer: $offer }) { - eip712Data - timestamp - salt - } - } -` - -gql` - mutation CreateOffer( - $offer: OfferInputBis! - $timestamp: Int! - $salt: String! - $signature: String! - ) { - createOffer( - input: { - offer: $offer - timestamp: $timestamp - salt: $salt - signature: $signature - } - ) { - offer { - id - } + currency(id: $currencyId) { + chainId + address } } ` @@ -77,52 +47,25 @@ export default function useCreateOffer( transactionHash: string | undefined }, ] { - const { sdk } = useContext(LiteflowContext) + const { sdk, client } = useContext(LiteflowContext) const [activeStep, setActiveProcess] = useState( CreateOfferStep.INITIAL, ) - const [ - approveCurrency, - { - activeStep: approveCurrencyActiveStep, - transactionHash: approveCurrencyTransactionHash, - }, - ] = useApproveCurrency(signer) - const [ - approveCollection, - { - activeStep: approveCollectionActiveStep, - transactionHash: approveCollectionTransactionHash, - }, - ] = useApproveCollection(signer) + const [transactionHash, setTransactionHash] = useState() - // sync approve currency active step - useEffect(() => { - switch (approveCurrencyActiveStep) { - case ApproveCurrencyStep.PENDING: { - setActiveProcess(CreateOfferStep.APPROVAL_PENDING) - break - } - case ApproveCurrencyStep.SIGNATURE: { + const updateProgress = useCallback( + ({ type, payload }) => { + if (type === 'APPROVAL_SIGNATURE') setActiveProcess(CreateOfferStep.APPROVAL_SIGNATURE) - break - } - } - }, [approveCurrencyActiveStep]) - - // sync approve collection active step - useEffect(() => { - switch (approveCollectionActiveStep) { - case ApproveCollectionStep.PENDING: { + if (type === 'APPROVAL_PENDING') { setActiveProcess(CreateOfferStep.APPROVAL_PENDING) - break - } - case ApproveCollectionStep.SIGNATURE: { - setActiveProcess(CreateOfferStep.APPROVAL_SIGNATURE) - break + setTransactionHash(payload.txHash) } - } - }, [approveCollectionActiveStep]) + if (type === 'OFFER_SIGNATURE') + setActiveProcess(CreateOfferStep.SIGNATURE) + }, + [setActiveProcess, setTransactionHash], + ) const createOffer = useCallback( async ({ @@ -144,72 +87,60 @@ export default function useCreateOffer( expiredAt: Date | null auctionId?: string }): Promise => { - invariant(signer, ErrorMessages.SIGNER_FALSY) - const account = await signer.getAddress() - + setActiveProcess(CreateOfferStep.INITIAL) try { - // approval if needed - if (type === 'SALE') { - // fetch asset - const { asset } = await sdk.FetchAssetForOffer({ assetId }) - invariant(asset, ErrorMessages.OFFER_CREATION_FAILED) - // creating a new offer of type sale, approval is on the asset - await approveCollection({ - chainId: asset.chainId, - collectionAddress: asset.collectionAddress, - }) - } else { - // creating a new offer of type buy, approval is on the currency - await approveCurrency({ - currencyId, - amount: quantity.mul(unitPrice), - }) - } + invariant(signer, ErrorMessages.SIGNER_FALSY) + const { asset, currency } = await sdk.FetchAssetForOffer({ + assetId, + currencyId, + }) + invariant(asset, ErrorMessages.OFFER_CREATION_FAILED) + invariant(currency, ErrorMessages.OFFER_CREATION_FAILED) - // fetch offer signature - setActiveProcess(CreateOfferStep.SIGNATURE) const offer = { - type, - makerAddress: account.toLowerCase(), - assetId: assetId, - currencyId: currencyId, - quantity: quantity.toString(), - unitPrice: unitPrice.toString(), - takerAddress: takerAddress?.toLowerCase() || null, - auctionId: auctionId || null, - expiredAt: expiredAt, + chain: asset.chainId, + collection: toAddress(asset.collectionAddress), + token: asset.tokenId, + quantity: quantity, + takerAddress: takerAddress ? toAddress(takerAddress) : undefined, + expiredAt: expiredAt || undefined, } - const { createOfferSignature } = await sdk.CreateOfferSignature({ - offer, - }) - const { eip712Data, timestamp, salt } = createOfferSignature - // sign data - const { domain, types, message /*, primaryType */ } = eip712Data - delete types.EIP712Domain // Hack: remove primary type from types to allow ethers detect the main type "Order" (aka: primaryType) - const signature = await signer._signTypedData(domain, types, message) + if (type === 'SALE') + return client.exchange.listToken( + { + ...offer, + unitPrice: { + amount: unitPrice, + currency: currency.address ? toAddress(currency.address) : null, + }, + }, + signer, + updateProgress, + ) + if (type === 'BUY') { + invariant(currency.address) + return client.exchange.placeBid( + { + ...offer, + unitPrice: { + amount: unitPrice, + currency: toAddress(currency.address), + }, + auctionId, + }, + signer, + updateProgress, + ) + } - // create offer - const { createOffer } = await sdk.CreateOffer({ - offer, - signature, - salt, - timestamp, - }) - return createOffer.offer.id + throw new Error(ErrorMessages.OFFER_CREATION_FAILED) } finally { setActiveProcess(CreateOfferStep.INITIAL) } }, - [approveCollection, approveCurrency, sdk, signer], + [sdk, signer, client, setActiveProcess, updateProgress], ) - return [ - createOffer, - { - activeStep, - transactionHash: - approveCurrencyTransactionHash || approveCollectionTransactionHash, - }, - ] + return [createOffer, { activeStep, transactionHash }] }