diff --git a/web3.js/module.flow.js b/web3.js/module.flow.js index 0eb885b639..e493feb7f8 100644 --- a/web3.js/module.flow.js +++ b/web3.js/module.flow.js @@ -233,92 +233,6 @@ declare module '@solana/web3.js' { serialize(): Buffer; } - // === src/token-program.js === - declare export class TokenAmount extends BN { - toBuffer(): Buffer; - fromBuffer(buffer: Buffer): TokenAmount; - } - - declare export type TokenInfo = {| - supply: TokenAmount, - decimals: number, - name: string, - symbol: string, - |}; - declare export type TokenAccountInfo = {| - token: PublicKey, - owner: PublicKey, - amount: TokenAmount, - source: null | PublicKey, - originalAmount: TokenAmount, - |}; - declare type TokenAndPublicKey = [Token, PublicKey]; - - declare export class Token { - programId: PublicKey; - token: PublicKey; - - static createNewToken( - connection: Connection, - owner: Account, - supply: TokenAmount, - name: string, - symbol: string, - decimals: number, - programId?: PublicKey, - ): Promise; - - constructor(connection: Connection, token: PublicKey): Token; - newAccount(owner: Account, source?: PublicKey): Promise; - tokenInfo(): Promise; - accountInfo(account: PublicKey): Promise; - transfer( - owner: Account, - source: PublicKey, - destination: PublicKey, - amount: number | TokenAmount, - ): Promise; - approve( - owner: Account, - account: PublicKey, - delegate: PublicKey, - amount: number | TokenAmount, - ): Promise; - revoke( - owner: Account, - account: PublicKey, - delegate: PublicKey, - ): Promise; - setOwner( - owner: Account, - account: PublicKey, - newOwner: PublicKey, - ): Promise; - - transferInstruction( - owner: PublicKey, - source: PublicKey, - destination: PublicKey, - amount: number | TokenAmount, - ): Promise; - approveInstruction( - owner: PublicKey, - account: PublicKey, - delegate: PublicKey, - amount: number | TokenAmount, - ): TransactionInstruction; - revokeInstruction( - owner: PublicKey, - account: PublicKey, - delegate: PublicKey, - ): TransactionInstruction; - setOwnerInstruction( - owner: PublicKey, - account: PublicKey, - newOwner: PublicKey, - ): TransactionInstruction; - } - // === src/loader.js === declare export class Loader { static load( diff --git a/web3.js/package-lock.json b/web3.js/package-lock.json index a50beeb0c0..4bf1c1799b 100644 --- a/web3.js/package-lock.json +++ b/web3.js/package-lock.json @@ -4851,15 +4851,6 @@ "integrity": "sha1-oMoMvCmltz6Dbuvhy/bF4OTrgvk=", "dev": true }, - "arr-diff": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-2.0.0.tgz", - "integrity": "sha1-jzuCf5Vai9ZpaX5KQlasPOrjVs8=", - "dev": true, - "requires": { - "arr-flatten": "^1.0.1" - } - }, "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", @@ -4928,12 +4919,6 @@ "integrity": "sha512-bdHxtev7FN6+MXI1YFW0Q8mQ8dTJc2S8AMfju+ZR77pbg2yAdVyDlwkaUI7Har0LyOMRFPHrJ9lYdyjZZswdlQ==", "dev": true }, - "array-unique": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz", - "integrity": "sha1-odl8yvy8JiXMcPrc6zalDFiwGlM=", - "dev": true - }, "array.prototype.flat": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.2.1.tgz", @@ -5530,17 +5515,6 @@ "concat-map": "0.0.1" } }, - "braces": { - "version": "1.8.5", - "resolved": "https://registry.npmjs.org/braces/-/braces-1.8.5.tgz", - "integrity": "sha1-uneWLhLf+WnWt2cR6RS3N4V79qc=", - "dev": true, - "requires": { - "expand-range": "^1.8.1", - "preserve": "^0.2.0", - "repeat-element": "^1.1.2" - } - }, "brorand": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", @@ -7894,12 +7868,6 @@ "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=", "dev": true }, - "estree-walker": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.0.tgz", - "integrity": "sha512-peq1RfVAVzr3PU/jL31RaOjUKLoZJpObQWJJ+LgfcxDUifyLZ1RjPQZTl0pzj2uJ45b7A7XpyppXvxdEqzo4rw==", - "dev": true - }, "esutils": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", @@ -7962,24 +7930,6 @@ "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", "dev": true }, - "expand-brackets": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-0.1.5.tgz", - "integrity": "sha1-3wcoTjQqgHzXM6xa9yQR5YHRF3s=", - "dev": true, - "requires": { - "is-posix-bracket": "^0.1.0" - } - }, - "expand-range": { - "version": "1.8.2", - "resolved": "https://registry.npmjs.org/expand-range/-/expand-range-1.8.2.tgz", - "integrity": "sha1-opnv/TNf4nIeuujiV+x5ZE/IUzc=", - "dev": true, - "requires": { - "fill-range": "^2.1.0" - } - }, "expect": { "version": "24.9.0", "resolved": "https://registry.npmjs.org/expect/-/expect-24.9.0.tgz", @@ -8043,15 +7993,6 @@ "tmp": "^0.0.33" } }, - "extglob": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz", - "integrity": "sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=", - "dev": true, - "requires": { - "is-extglob": "^1.0.0" - } - }, "extsprintf": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", @@ -8207,25 +8148,6 @@ "flat-cache": "^2.0.1" } }, - "filename-regex": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.1.tgz", - "integrity": "sha1-wcS5vuPglyXdsQa3XB4wH+LxiyY=", - "dev": true - }, - "fill-range": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-2.2.3.tgz", - "integrity": "sha1-ULd9/X5Gm8dJJHCWNpn+eoSFpyM=", - "dev": true, - "requires": { - "is-number": "^2.1.0", - "isobject": "^2.0.0", - "randomatic": "^1.1.3", - "repeat-element": "^1.1.2", - "repeat-string": "^1.5.2" - } - }, "find-babel-config": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-babel-config/-/find-babel-config-1.1.0.tgz", @@ -8407,15 +8329,6 @@ "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=" }, - "for-own": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/for-own/-/for-own-0.1.5.tgz", - "integrity": "sha1-UmXGgaTylNq78XyVCbZ2OqhFEM4=", - "dev": true, - "requires": { - "for-in": "^1.0.1" - } - }, "foreach": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.5.tgz", @@ -9233,25 +9146,6 @@ "path-is-absolute": "^1.0.0" } }, - "glob-base": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/glob-base/-/glob-base-0.3.0.tgz", - "integrity": "sha1-27Fk9iIbHAscz4Kuoyi0l98Oo8Q=", - "dev": true, - "requires": { - "glob-parent": "^2.0.0", - "is-glob": "^2.0.0" - } - }, - "glob-parent": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-2.0.0.tgz", - "integrity": "sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=", - "dev": true, - "requires": { - "is-glob": "^2.0.0" - } - }, "global-dirs": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/global-dirs/-/global-dirs-0.1.1.tgz", @@ -9366,9 +9260,9 @@ "dev": true }, "handlebars": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.1.2.tgz", - "integrity": "sha512-nvfrjqvt9xQ8Z/w0ijewdD/vvWDTOweBUm96NTr66Wfvo1mJenBLwcYmPs3TIBP5ruzYGD7Hx/DaM9RmhroGPw==", + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.4.0.tgz", + "integrity": "sha512-xkRtOt3/3DzTKMOt3xahj2M/EqNhY988T+imYSlMgs5fVhLN2fmKVVj0LtEGmb+3UUYV5Qmm1052Mm3dIQxOvw==", "dev": true, "requires": { "neo-async": "^2.6.0", @@ -10180,32 +10074,11 @@ "integrity": "sha1-YTObbyR1/Hcv2cnYP1yFddwVSuE=", "dev": true }, - "is-dotfile": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/is-dotfile/-/is-dotfile-1.0.3.tgz", - "integrity": "sha1-pqLzL/0t+wT1yiXs0Pa4PPeYoeE=", - "dev": true - }, - "is-equal-shallow": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz", - "integrity": "sha1-IjgJj8Ih3gvPpdnqxMRdY4qhxTQ=", - "dev": true, - "requires": { - "is-primitive": "^2.0.0" - } - }, "is-extendable": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=" }, - "is-extglob": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz", - "integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=", - "dev": true - }, "is-finite": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.0.2.tgz", @@ -10227,30 +10100,12 @@ "integrity": "sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ==", "dev": true }, - "is-glob": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", - "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", - "dev": true, - "requires": { - "is-extglob": "^1.0.0" - } - }, "is-module": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", "integrity": "sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE=", "dev": true }, - "is-number": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz", - "integrity": "sha1-Afy7s5NGOlSPL0ZszhbezknbkI8=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - } - }, "is-number-object": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.3.tgz", @@ -10307,18 +10162,6 @@ } } }, - "is-posix-bracket": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz", - "integrity": "sha1-MzTceXdDaOkvAW5vvAqI9c1ua8Q=", - "dev": true - }, - "is-primitive": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-primitive/-/is-primitive-2.0.0.tgz", - "integrity": "sha1-IHurkWOEmcB7Kt8kCkGochADRXU=", - "dev": true - }, "is-promise": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", @@ -10414,15 +10257,6 @@ "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" }, - "isobject": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", - "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", - "dev": true, - "requires": { - "isarray": "1.0.0" - } - }, "isstream": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", @@ -13807,27 +13641,6 @@ "integrity": "sha512-FYE8xI+6pjFOhokZu0We3S5NKCirLbCzSh2Usf3qEyr4X8U+0jNg9P8RZ4qz+V2UoECLVwSyzU3LxXBaLGtD3A==", "dev": true }, - "micromatch": { - "version": "2.3.11", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz", - "integrity": "sha1-hmd8l9FyCzY0MdBNDRUpO9OMFWU=", - "dev": true, - "requires": { - "arr-diff": "^2.0.0", - "array-unique": "^0.2.1", - "braces": "^1.8.2", - "expand-brackets": "^0.1.4", - "extglob": "^0.3.1", - "filename-regex": "^2.0.0", - "is-extglob": "^1.0.0", - "is-glob": "^2.0.1", - "kind-of": "^3.0.2", - "normalize-path": "^2.0.1", - "object.omit": "^2.0.0", - "parse-glob": "^3.0.4", - "regex-cache": "^0.4.2" - } - }, "miller-rabin": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz", @@ -14061,9 +13874,9 @@ } }, "neo-async": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.0.tgz", - "integrity": "sha512-MFh0d/Wa7vkKO3Y3LlacqAEeHK0mckVqzDieUKTT+KGxi+zIpeVsFxymkIiRpbpDziHc290Xr9A1O4Om7otoRA==", + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.1.tgz", + "integrity": "sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw==", "dev": true }, "nerf-dart": { @@ -17944,16 +17757,6 @@ "es-abstract": "^1.5.1" } }, - "object.omit": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/object.omit/-/object.omit-2.0.1.tgz", - "integrity": "sha1-Gpx0SCnznbuFjHbKNXmuKlTr0fo=", - "dev": true, - "requires": { - "for-own": "^0.1.4", - "is-extendable": "^0.1.1" - } - }, "object.pick": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", @@ -18258,18 +18061,6 @@ "integrity": "sha512-kgBf6avCbO3Cn6+RnzRGLkUsv4ZVqv/VfAYkRsyBcgkshNvVBkRn1FEZcW0Jb+npXQWm2vHPnnOqFteZxRRGNw==", "dev": true }, - "parse-glob": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz", - "integrity": "sha1-ssN2z7EfNVE7rdFz7wu246OIORw=", - "dev": true, - "requires": { - "glob-base": "^0.3.0", - "is-dotfile": "^1.0.0", - "is-extglob": "^1.0.0", - "is-glob": "^2.0.0" - } - }, "parse-json": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", @@ -18453,12 +18244,6 @@ "integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=", "dev": true }, - "preserve": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/preserve/-/preserve-0.2.0.tgz", - "integrity": "sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=", - "dev": true - }, "prettier": { "version": "1.18.2", "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.18.2.tgz", @@ -18646,47 +18431,6 @@ "ret": "~0.1.10" } }, - "randomatic": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", - "dev": true, - "requires": { - "is-number": "^3.0.0", - "kind-of": "^4.0.0" - }, - "dependencies": { - "is-number": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", - "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "kind-of": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", - "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, "randombytes": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.6.tgz", @@ -18843,15 +18587,6 @@ "private": "^0.1.6" } }, - "regex-cache": { - "version": "0.4.4", - "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", - "dev": true, - "requires": { - "is-equal-shallow": "^0.1.3" - } - }, "regex-escape": { "version": "3.4.8", "resolved": "https://registry.npmjs.org/regex-escape/-/regex-escape-3.4.8.tgz", @@ -19231,289 +18966,22 @@ "rollup-pluginutils": "^2.5.0" }, "dependencies": { - "arr-diff": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", - "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", - "dev": true - }, - "array-unique": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", - "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", - "dev": true - }, - "braces": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", - "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", + "rollup-pluginutils": { + "version": "2.8.2", + "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz", + "integrity": "sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==", "dev": true, "requires": { - "arr-flatten": "^1.1.0", - "array-unique": "^0.3.2", - "extend-shallow": "^2.0.1", - "fill-range": "^4.0.0", - "isobject": "^3.0.1", - "repeat-element": "^1.1.2", - "snapdragon": "^0.8.1", - "snapdragon-node": "^2.0.1", - "split-string": "^3.0.2", - "to-regex": "^3.0.1" + "estree-walker": "^0.6.1" }, "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "expand-brackets": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", - "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", - "dev": true, - "requires": { - "debug": "^2.3.3", - "define-property": "^0.2.5", - "extend-shallow": "^2.0.1", - "posix-character-classes": "^0.1.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "^0.1.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - }, - "is-accessor-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "is-data-descriptor": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "is-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", - "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "^0.1.6", - "is-data-descriptor": "^0.1.4", - "kind-of": "^5.0.0" - } - }, - "kind-of": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", - "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", + "estree-walker": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.1.tgz", + "integrity": "sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==", "dev": true } } - }, - "extglob": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", - "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", - "dev": true, - "requires": { - "array-unique": "^0.3.2", - "define-property": "^1.0.0", - "expand-brackets": "^2.1.4", - "extend-shallow": "^2.0.1", - "fragment-cache": "^0.2.1", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "requires": { - "is-descriptor": "^1.0.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "fill-range": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", - "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", - "dev": true, - "requires": { - "extend-shallow": "^2.0.1", - "is-number": "^3.0.0", - "repeat-string": "^1.6.1", - "to-regex-range": "^2.1.0" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - }, - "is-number": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", - "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true - }, - "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", - "dev": true - }, - "micromatch": { - "version": "3.1.10", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", - "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", - "dev": true, - "requires": { - "arr-diff": "^4.0.0", - "array-unique": "^0.3.2", - "braces": "^2.3.1", - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "extglob": "^2.0.4", - "fragment-cache": "^0.2.1", - "kind-of": "^6.0.2", - "nanomatch": "^1.2.9", - "object.pick": "^1.3.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.2" - } - }, - "rollup-pluginutils": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.5.0.tgz", - "integrity": "sha512-9Muh1H+XB5f5ONmKMayUoTYR1EZwHbwJJ9oZLrKT5yuTf/RLIQ5mYIGsrERquVucJmjmaAW0Y7+6Qo1Ep+5w3Q==", - "dev": true, - "requires": { - "estree-walker": "^0.6.0", - "micromatch": "^3.1.10" - } } } }, @@ -19556,13 +19024,20 @@ "dev": true }, "rollup-pluginutils": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.3.3.tgz", - "integrity": "sha512-2XZwja7b6P5q4RZ5FhyX1+f46xi1Z3qBKigLRZ6VTZjwbN0K1IFGMlwm06Uu0Emcre2Z63l77nq/pzn+KxIEoA==", + "version": "2.8.2", + "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz", + "integrity": "sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==", "dev": true, "requires": { - "estree-walker": "^0.5.2", - "micromatch": "^2.3.11" + "estree-walker": "^0.6.1" + }, + "dependencies": { + "estree-walker": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.1.tgz", + "integrity": "sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==", + "dev": true + } } } } @@ -19613,259 +19088,6 @@ "rollup-pluginutils": "^2.6.0" }, "dependencies": { - "arr-diff": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", - "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", - "dev": true - }, - "array-unique": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", - "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", - "dev": true - }, - "braces": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", - "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", - "dev": true, - "requires": { - "arr-flatten": "^1.1.0", - "array-unique": "^0.3.2", - "extend-shallow": "^2.0.1", - "fill-range": "^4.0.0", - "isobject": "^3.0.1", - "repeat-element": "^1.1.2", - "snapdragon": "^0.8.1", - "snapdragon-node": "^2.0.1", - "split-string": "^3.0.2", - "to-regex": "^3.0.1" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "expand-brackets": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", - "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", - "dev": true, - "requires": { - "debug": "^2.3.3", - "define-property": "^0.2.5", - "extend-shallow": "^2.0.1", - "posix-character-classes": "^0.1.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "^0.1.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - }, - "is-accessor-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "is-data-descriptor": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "is-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", - "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "^0.1.6", - "is-data-descriptor": "^0.1.4", - "kind-of": "^5.0.0" - } - }, - "kind-of": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", - "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "dev": true - } - } - }, - "extglob": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", - "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", - "dev": true, - "requires": { - "array-unique": "^0.3.2", - "define-property": "^1.0.0", - "expand-brackets": "^2.1.4", - "extend-shallow": "^2.0.1", - "fragment-cache": "^0.2.1", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "requires": { - "is-descriptor": "^1.0.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "fill-range": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", - "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", - "dev": true, - "requires": { - "extend-shallow": "^2.0.1", - "is-number": "^3.0.0", - "repeat-string": "^1.6.1", - "to-regex-range": "^2.1.0" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - }, - "is-number": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", - "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true - }, - "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", - "dev": true - }, "magic-string": { "version": "0.25.2", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.2.tgz", @@ -19875,35 +19097,21 @@ "sourcemap-codec": "^1.4.4" } }, - "micromatch": { - "version": "3.1.10", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", - "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", - "dev": true, - "requires": { - "arr-diff": "^4.0.0", - "array-unique": "^0.3.2", - "braces": "^2.3.1", - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "extglob": "^2.0.4", - "fragment-cache": "^0.2.1", - "kind-of": "^6.0.2", - "nanomatch": "^1.2.9", - "object.pick": "^1.3.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.2" - } - }, "rollup-pluginutils": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.6.0.tgz", - "integrity": "sha512-aGQwspEF8oPKvg37u3p7h0cYNwmJR1sCBMZGZ5b9qy8HGtETknqjzcxrDRrcAnJNXN18lBH4Q9vZYth/p4n8jQ==", + "version": "2.8.2", + "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz", + "integrity": "sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==", "dev": true, "requires": { - "estree-walker": "^0.6.0", - "micromatch": "^3.1.10" + "estree-walker": "^0.6.1" + }, + "dependencies": { + "estree-walker": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.1.tgz", + "integrity": "sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==", + "dev": true + } } } } @@ -20735,9 +19943,9 @@ "dev": true }, "set-value": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz", - "integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", + "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==", "dev": true, "requires": { "extend-shallow": "^2.0.1", @@ -21964,9 +21172,9 @@ "dev": true }, "uglify-js": { - "version": "3.5.10", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.5.10.tgz", - "integrity": "sha512-/GTF0nosyPLbdJBd+AwYiZ+Hu5z8KXWnO0WCGt1BQ/u9Iamhejykqmz5o1OHJ53+VAk6xVxychonnApDjuqGsw==", + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.0.tgz", + "integrity": "sha512-W+jrUHJr3DXKhrsS7NUVxn3zqMOFn0hL/Ei6v0anCIMoKC93TjcflTagwIHLW7SfMFfiQuktQyFVCFHGUE0+yg==", "dev": true, "optional": true, "requires": { @@ -21975,9 +21183,9 @@ }, "dependencies": { "commander": { - "version": "2.20.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz", - "integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==", + "version": "2.20.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.1.tgz", + "integrity": "sha512-cCuLsMhJeWQ/ZpsFTbE765kvVfoeSddc4nU3up4fV+fDBcfUXnbITJ+JzhkdjzOqhURjZgujxaioam4RM9yGUg==", "dev": true, "optional": true }, @@ -22019,38 +21227,15 @@ "dev": true }, "union-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz", - "integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz", + "integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==", "dev": true, "requires": { "arr-union": "^3.1.0", "get-value": "^2.0.6", "is-extendable": "^0.1.1", - "set-value": "^0.4.3" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - }, - "set-value": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-0.4.3.tgz", - "integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=", - "dev": true, - "requires": { - "extend-shallow": "^2.0.1", - "is-extendable": "^0.1.1", - "is-plain-object": "^2.0.1", - "to-object-path": "^0.3.0" - } - } + "set-value": "^2.0.1" } }, "universal-user-agent": { diff --git a/web3.js/src/index.js b/web3.js/src/index.js index b413599938..f719bc00ac 100644 --- a/web3.js/src/index.js +++ b/web3.js/src/index.js @@ -6,7 +6,6 @@ export {Connection} from './connection'; export {Loader} from './loader'; export {PublicKey} from './publickey'; export {SystemInstruction, SystemProgram} from './system-program'; -export {Token, TokenAmount} from './token-program'; export {Transaction, TransactionInstruction} from './transaction'; export {VALIDATOR_INFO_KEY, ValidatorInfo} from './validator-info'; export {VOTE_ACCOUNT_KEY, VoteAccount} from './vote-account'; diff --git a/web3.js/src/token-program.js b/web3.js/src/token-program.js deleted file mode 100644 index 1244db7364..0000000000 --- a/web3.js/src/token-program.js +++ /dev/null @@ -1,603 +0,0 @@ -/** - * @flow - */ - -import assert from 'assert'; -import BN from 'bn.js'; -import * as BufferLayout from 'buffer-layout'; - -import * as Layout from './layout'; -import {Account} from './account'; -import {PublicKey} from './publickey'; -import {SystemProgram} from './system-program'; -import {Transaction, TransactionInstruction} from './transaction'; -import type {TransactionSignature} from './transaction'; -import {sendAndConfirmTransaction} from './util/send-and-confirm-transaction'; -import type {Connection} from './connection'; - -/** - * Some amount of tokens - */ -export class TokenAmount extends BN { - /** - * Convert to Buffer representation - */ - toBuffer(): Buffer { - const a = super.toArray().reverse(); - const b = Buffer.from(a); - if (b.length === 8) { - return b; - } - assert(b.length < 8, 'TokenAmount too large'); - - const zeroPad = Buffer.alloc(8); - b.copy(zeroPad); - return zeroPad; - } - - /** - * Construct a TokenAmount from Buffer representation - */ - static fromBuffer(buffer: Buffer): TokenAmount { - assert(buffer.length === 8, `Invalid buffer length: ${buffer.length}`); - return new BN( - [...buffer] - .reverse() - .map(i => `00${i.toString(16)}`.slice(-2)) - .join(''), - 16, - ); - } -} - -/** - * Information about a token - */ -type TokenInfo = {| - /** - * Total supply of tokens - */ - supply: TokenAmount, - - /** - * Number of base 10 digits to the right of the decimal place - */ - decimals: number, - - /** - * Descriptive name of this token - */ - name: string, - - /** - * Symbol for this token - */ - symbol: string, -|}; - -/** - * @private - */ -const TokenInfoLayout = BufferLayout.struct([ - Layout.uint64('supply'), - BufferLayout.u8('decimals'), - Layout.rustString('name'), - Layout.rustString('symbol'), -]); - -/** - * Information about a token account - */ -type TokenAccountInfo = {| - /** - * The kind of token this account holds - */ - token: PublicKey, - - /** - * Owner of this account - */ - owner: PublicKey, - - /** - * Amount of tokens this account holds - */ - amount: TokenAmount, - - /** - * The source account for the tokens. - * - * If `source` is null, the source is this account. - * If `source` is not null, the `amount` of tokens in this account represent - * an allowance of tokens that may be transferred from the source account - */ - source: null | PublicKey, - - /** - * Original amount of tokens this delegate account was authorized to spend - * If `source` is null, originalAmount is zero - */ - originalAmount: TokenAmount, -|}; - -/** - * @private - */ -const TokenAccountInfoLayout = BufferLayout.struct([ - Layout.publicKey('token'), - Layout.publicKey('owner'), - Layout.uint64('amount'), - BufferLayout.u8('sourceOption'), - Layout.publicKey('source'), - Layout.uint64('originalAmount'), -]); - -type TokenAndPublicKey = [Token, PublicKey]; // This type exists to workaround an esdoc parse error - -/** - * The built-in token program - */ -export const SYSTEM_TOKEN_PROGRAM_ID = new PublicKey( - 'Token11111111111111111111111111111111111111', -); - -/** - * An ERC20-like Token - */ -export class Token { - /** - * @private - */ - connection: Connection; - - /** - * The public key identifying this token - */ - token: PublicKey; - - /** - * Program Identifier for the Token program - */ - programId: PublicKey; - - /** - * Create a Token object attached to the specific token - * - * @param connection The connection to use - * @param token Public key of the token - * @param programId Optional token programId, uses the system programId by default - */ - constructor( - connection: Connection, - token: PublicKey, - programId: PublicKey = SYSTEM_TOKEN_PROGRAM_ID, - ) { - Object.assign(this, {connection, token, programId}); - } - - /** - * Create a new Token - * - * @param connection The connection to use - * @param owner User account that will own the returned Token Account - * @param supply Total supply of the new token - * @param name Descriptive name of this token - * @param symbol Symbol for this token - * @param decimals Location of the decimal place - * @param programId Optional token programId, uses the system programId by default - * @return Token object for the newly minted token, Public key of the Token Account holding the total supply of new tokens - */ - static async createNewToken( - connection: Connection, - owner: Account, - supply: TokenAmount, - name: string, - symbol: string, - decimals: number, - programId: PublicKey = SYSTEM_TOKEN_PROGRAM_ID, - ): Promise { - const tokenAccount = new Account(); - const token = new Token(connection, tokenAccount.publicKey, programId); - const initialAccountPublicKey = await token.newAccount(owner, null); - - let transaction; - - const dataLayout = BufferLayout.struct([ - BufferLayout.u32('instruction'), - Layout.uint64('supply'), - BufferLayout.u8('decimals'), - Layout.rustString('name'), - Layout.rustString('symbol'), - ]); - - let data = Buffer.alloc(1024); - { - const encodeLength = dataLayout.encode( - { - instruction: 0, // NewToken instruction - supply: supply.toBuffer(), - decimals, - name, - symbol, - }, - data, - ); - data = data.slice(0, encodeLength); - } - - // Allocate memory for the tokenAccount account - transaction = SystemProgram.createAccount( - owner.publicKey, - tokenAccount.publicKey, - 1, - 1 + data.length, - programId, - ); - await sendAndConfirmTransaction(connection, transaction, owner); - - transaction = new Transaction().add({ - keys: [ - {pubkey: tokenAccount.publicKey, isSigner: true, isDebitable: false}, - {pubkey: initialAccountPublicKey, isSigner: false, isDebitable: true}, - ], - programId, - data, - }); - await sendAndConfirmTransaction( - connection, - transaction, - owner, - tokenAccount, - ); - - return [token, initialAccountPublicKey]; - } - - /** - * Create a new and empty token account. - * - * This account may then be used as a `transfer()` or `approve()` destination - * - * @param owner User account that will own the new token account - * @param source If not null, create a delegate account that when authorized - * may transfer tokens from this `source` account - * @return Public key of the new empty token account - */ - async newAccount( - owner: Account, - source: null | PublicKey = null, - ): Promise { - const tokenAccount = new Account(); - let transaction; - - const dataLayout = BufferLayout.struct([BufferLayout.u32('instruction')]); - - const data = Buffer.alloc(dataLayout.span); - dataLayout.encode( - { - instruction: 1, // NewTokenAccount instruction - }, - data, - ); - - // Allocate memory for the token - transaction = SystemProgram.createAccount( - owner.publicKey, - tokenAccount.publicKey, - 1, - 1 + TokenAccountInfoLayout.span, - this.programId, - ); - await sendAndConfirmTransaction(this.connection, transaction, owner); - - // Initialize the token account - const keys = [ - {pubkey: tokenAccount.publicKey, isSigner: true, isDebitable: true}, - {pubkey: owner.publicKey, isSigner: false, isDebitable: false}, - {pubkey: this.token, isSigner: false, isDebitable: false}, - ]; - if (source) { - keys.push({pubkey: source, isSigner: false, isDebitable: false}); - } - transaction = new Transaction().add({ - keys, - programId: this.programId, - data, - }); - await sendAndConfirmTransaction( - this.connection, - transaction, - owner, - tokenAccount, - ); - - return tokenAccount.publicKey; - } - - /** - * Retrieve token information - */ - async tokenInfo(): Promise { - const accountInfo = await this.connection.getAccountInfo(this.token); - if (!accountInfo.owner.equals(this.programId)) { - throw new Error( - `Invalid token owner: ${JSON.stringify(accountInfo.owner)}`, - ); - } - - const data = Buffer.from(accountInfo.data); - - if (data.readUInt8(0) !== 1) { - throw new Error(`Invalid token data`); - } - const tokenInfo = TokenInfoLayout.decode(data, 1); - tokenInfo.supply = TokenAmount.fromBuffer(tokenInfo.supply); - return tokenInfo; - } - - /** - * Retrieve account information - * - * @param account Public key of the token account - */ - async accountInfo(account: PublicKey): Promise { - const accountInfo = await this.connection.getAccountInfo(account); - if (!accountInfo.owner.equals(this.programId)) { - throw new Error(`Invalid token account owner`); - } - - const data = Buffer.from(accountInfo.data); - if (data.readUInt8(0) !== 2) { - throw new Error(`Invalid token account data`); - } - const tokenAccountInfo = TokenAccountInfoLayout.decode(data, 1); - - tokenAccountInfo.token = new PublicKey(tokenAccountInfo.token); - tokenAccountInfo.owner = new PublicKey(tokenAccountInfo.owner); - tokenAccountInfo.amount = TokenAmount.fromBuffer(tokenAccountInfo.amount); - if (tokenAccountInfo.sourceOption === 0) { - tokenAccountInfo.source = null; - tokenAccountInfo.originalAmount = new TokenAmount(); - } else { - tokenAccountInfo.source = new PublicKey(tokenAccountInfo.source); - tokenAccountInfo.originalAmount = TokenAmount.fromBuffer( - tokenAccountInfo.originalAmount, - ); - } - - if (!tokenAccountInfo.token.equals(this.token)) { - throw new Error( - `Invalid token account token: ${JSON.stringify( - tokenAccountInfo.token, - )} !== ${JSON.stringify(this.token)}`, - ); - } - return tokenAccountInfo; - } - - /** - * Transfer tokens to another account - * - * @param owner Owner of the source token account - * @param source Source token account - * @param destination Destination token account - * @param amount Number of tokens to transfer - */ - async transfer( - owner: Account, - source: PublicKey, - destination: PublicKey, - amount: number | TokenAmount, - ): Promise { - return await sendAndConfirmTransaction( - this.connection, - new Transaction().add( - await this.transferInstruction( - owner.publicKey, - source, - destination, - amount, - ), - ), - owner, - ); - } - - /** - * Grant a third-party permission to transfer up the specified number of tokens from an account - * - * @param owner Owner of the source token account - * @param account Public key of the token account - * @param delegate Token account authorized to perform a transfer tokens from the source account - * @param amount Maximum number of tokens the delegate may transfer - */ - async approve( - owner: Account, - account: PublicKey, - delegate: PublicKey, - amount: number | TokenAmount, - ): Promise { - await sendAndConfirmTransaction( - this.connection, - new Transaction().add( - this.approveInstruction(owner.publicKey, account, delegate, amount), - ), - owner, - ); - } - - /** - * Remove approval for the transfer of any remaining tokens - * - * @param owner Owner of the source token account - * @param account Public key of the token account - * @param delegate Token account to revoke authorization from - */ - revoke( - owner: Account, - account: PublicKey, - delegate: PublicKey, - ): Promise { - return this.approve(owner, account, delegate, 0); - } - - /** - * Assign a new owner to the account - * - * @param owner Owner of the token account - * @param account Public key of the token account - * @param newOwner New owner of the token account - */ - async setOwner( - owner: Account, - account: PublicKey, - newOwner: PublicKey, - ): Promise { - await sendAndConfirmTransaction( - this.connection, - new Transaction().add( - this.setOwnerInstruction(owner.publicKey, account, newOwner), - ), - owner, - ); - } - - /** - * Construct a Transfer instruction - * - * @param owner Owner of the source token account - * @param source Source token account - * @param destination Destination token account - * @param amount Number of tokens to transfer - */ - async transferInstruction( - owner: PublicKey, - source: PublicKey, - destination: PublicKey, - amount: number | TokenAmount, - ): Promise { - const accountInfo = await this.accountInfo(source); - if (!owner.equals(accountInfo.owner)) { - throw new Error('Account owner mismatch'); - } - - const dataLayout = BufferLayout.struct([ - BufferLayout.u32('instruction'), - Layout.uint64('amount'), - ]); - - const data = Buffer.alloc(dataLayout.span); - dataLayout.encode( - { - instruction: 2, // Transfer instruction - amount: new TokenAmount(amount).toBuffer(), - }, - data, - ); - - const keys = [ - {pubkey: owner, isSigner: true, isDebitable: false}, - {pubkey: source, isSigner: false, isDebitable: true}, - {pubkey: destination, isSigner: false, isDebitable: true}, - ]; - if (accountInfo.source) { - keys.push({ - pubkey: accountInfo.source, - isSigner: false, - isDebitable: true, - }); - } - return new TransactionInstruction({ - keys, - programId: this.programId, - data, - }); - } - - /** - * Construct an Approve instruction - * - * @param owner Owner of the source token account - * @param account Public key of the token account - * @param delegate Token account authorized to perform a transfer tokens from the source account - * @param amount Maximum number of tokens the delegate may transfer - */ - approveInstruction( - owner: PublicKey, - account: PublicKey, - delegate: PublicKey, - amount: number | TokenAmount, - ): TransactionInstruction { - const dataLayout = BufferLayout.struct([ - BufferLayout.u32('instruction'), - Layout.uint64('amount'), - ]); - - const data = Buffer.alloc(dataLayout.span); - dataLayout.encode( - { - instruction: 3, // Approve instruction - amount: new TokenAmount(amount).toBuffer(), - }, - data, - ); - - return new TransactionInstruction({ - keys: [ - {pubkey: owner, isSigner: true, isDebitable: false}, - {pubkey: account, isSigner: false, isDebitable: true}, - {pubkey: delegate, isSigner: false, isDebitable: true}, - ], - programId: this.programId, - data, - }); - } - - /** - * Construct an Revoke instruction - * - * @param owner Owner of the source token account - * @param account Public key of the token account - * @param delegate Token account authorized to perform a transfer tokens from the source account - */ - revokeInstruction( - owner: PublicKey, - account: PublicKey, - delegate: PublicKey, - ): TransactionInstruction { - return this.approveInstruction(owner, account, delegate, 0); - } - - /** - * Construct a SetOwner instruction - * - * @param owner Owner of the token account - * @param account Public key of the token account - * @param newOwner New owner of the token account - */ - setOwnerInstruction( - owner: PublicKey, - account: PublicKey, - newOwner: PublicKey, - ): TransactionInstruction { - const dataLayout = BufferLayout.struct([BufferLayout.u32('instruction')]); - - const data = Buffer.alloc(dataLayout.span); - dataLayout.encode( - { - instruction: 4, // SetOwner instruction - }, - data, - ); - - return new TransactionInstruction({ - keys: [ - {pubkey: owner, isSigner: true, isDebitable: false}, - {pubkey: account, isSigner: false, isDebitable: true}, - {pubkey: newOwner, isSigner: false, isDebitable: true}, - ], - programId: this.programId, - data, - }); - } -} diff --git a/web3.js/test/token-program.test.js b/web3.js/test/token-program.test.js deleted file mode 100644 index e2e37b2f8c..0000000000 --- a/web3.js/test/token-program.test.js +++ /dev/null @@ -1,609 +0,0 @@ -// @flow - -import {Connection, PublicKey, Token, TokenAmount} from '../src'; -import {SYSTEM_TOKEN_PROGRAM_ID} from '../src/token-program'; -import {mockRpc, mockRpcEnabled} from './__mocks__/node-fetch'; -import {url} from './url'; -import {newAccountWithLamports} from './new-account-with-lamports'; -import {mockGetRecentBlockhash} from './mockrpc/get-recent-blockhash'; -import {sleep} from '../src/util/sleep'; - -// The default of 5 seconds is too slow for live testing sometimes -jest.setTimeout(60000); - -function mockGetSignatureStatus(result: Object = {Ok: null}) { - mockRpc.push([ - url, - { - method: 'getSignatureStatus', - }, - { - error: null, - result, - }, - ]); -} -function mockSendTransaction() { - mockRpc.push([ - url, - { - method: 'sendTransaction', - }, - { - error: null, - result: - '3WE5w4B7v59x6qjyC4FbG2FEKYKQfvsJwqSxNVmtMjT8TQ31hsZieDHcSgqzxiAoTL56n2w5TncjqEKjLhtF4Vk', - }, - ]); -} - -// A token created by the first test and used by all subsequent tests -let testToken: Token; - -// Initial owner of the token supply -let initialOwner; -let initialOwnerTokenAccount: PublicKey; - -test('create new token', async () => { - const connection = new Connection(url); - connection._disableBlockhashCaching = mockRpcEnabled; - - initialOwner = await newAccountWithLamports(connection, 1024); - - { - // mock SystemProgram.createAccount transaction for Token.createNewToken() - mockGetRecentBlockhash(); - mockSendTransaction(); - mockGetSignatureStatus(); - - // mock Token.newAccount() transaction - mockSendTransaction(); - mockGetSignatureStatus(null); - mockGetSignatureStatus(); - - // mock SystemProgram.createAccount transaction for Token.createNewToken() - mockSendTransaction(); - mockGetSignatureStatus(); - - // mock Token.createNewToken() transaction - mockSendTransaction(); - mockGetSignatureStatus(null); - mockGetSignatureStatus(); - } - - [testToken, initialOwnerTokenAccount] = await Token.createNewToken( - connection, - initialOwner, - new TokenAmount(10000), - 'Test token', - 'TEST', - 2, - ); - - { - // mock Token.tokenInfo()'s getAccountInfo - mockRpc.push([ - url, - { - method: 'getAccountInfo', - params: [testToken.token.toBase58()], - }, - { - error: null, - result: { - owner: [...SYSTEM_TOKEN_PROGRAM_ID.toBuffer()], - lamports: 1, - data: [ - 1, - 16, - 39, - 0, - 0, - 0, - 0, - 0, - 0, - 2, - 10, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 84, - 101, - 115, - 116, - 32, - 116, - 111, - 107, - 101, - 110, - 4, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 84, - 69, - 83, - 84, - ], - executable: false, - }, - }, - ]); - } - - const tokenInfo = await testToken.tokenInfo(); - - expect(tokenInfo.supply.toNumber()).toBe(10000); - expect(tokenInfo.decimals).toBe(2); - expect(tokenInfo.name).toBe('Test token'); - expect(tokenInfo.symbol).toBe('TEST'); - - { - // mock Token.accountInfo()'s getAccountInfo - mockRpc.push([ - url, - { - method: 'getAccountInfo', - params: [initialOwnerTokenAccount.toBase58()], - }, - { - error: null, - result: { - owner: [...SYSTEM_TOKEN_PROGRAM_ID.toBuffer()], - lamports: 1, - data: [ - 2, - ...testToken.token.toBuffer(), - ...initialOwner.publicKey.toBuffer(), - 16, - 39, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - ], - executable: false, - }, - }, - ]); - } - - const accountInfo = await testToken.accountInfo(initialOwnerTokenAccount); - - expect(accountInfo.token.equals(testToken.token)).toBe(true); - expect(accountInfo.owner.equals(initialOwner.publicKey)).toBe(true); - expect(accountInfo.amount.toNumber()).toBe(10000); - expect(accountInfo.source).toBe(null); - expect(accountInfo.originalAmount.toNumber()).toBe(0); -}); - -test('create new token account', async () => { - const connection = new Connection(url); - connection._disableBlockhashCaching = mockRpcEnabled; - const destOwner = await newAccountWithLamports(connection); - - { - // mock SystemProgram.createAccount transaction for Token.newAccount() - mockSendTransaction(); - mockGetSignatureStatus(); - - // mock Token.newAccount() transaction - mockSendTransaction(); - mockGetSignatureStatus(); - } - - const dest = await testToken.newAccount(destOwner); - { - // mock Token.accountInfo()'s getAccountInfo - mockRpc.push([ - url, - { - method: 'getAccountInfo', - params: [dest.toBase58()], - }, - { - error: null, - result: { - owner: [...SYSTEM_TOKEN_PROGRAM_ID.toBuffer()], - lamports: 1, - data: [ - 2, - ...testToken.token.toBuffer(), - ...destOwner.publicKey.toBuffer(), - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - ], - executable: false, - }, - }, - ]); - } - - const accountInfo = await testToken.accountInfo(dest); - - expect(accountInfo.token.equals(testToken.token)).toBe(true); - expect(accountInfo.owner.equals(destOwner.publicKey)).toBe(true); - expect(accountInfo.amount.toNumber()).toBe(0); - expect(accountInfo.source).toBe(null); -}); - -test('transfer', async () => { - const connection = new Connection(url); - connection._disableBlockhashCaching = mockRpcEnabled; - const destOwner = await newAccountWithLamports(connection); - - { - // mock SystemProgram.createAccount transaction for Token.newAccount() - mockSendTransaction(); - mockGetSignatureStatus(); - - // mock Token.newAccount() transaction - mockSendTransaction(); - mockGetSignatureStatus(); - } - - const dest = await testToken.newAccount(destOwner); - - { - // mock Token.transfer()'s getAccountInfo - mockRpc.push([ - url, - { - method: 'getAccountInfo', - params: [initialOwnerTokenAccount.toBase58()], - }, - { - error: null, - result: { - owner: [...SYSTEM_TOKEN_PROGRAM_ID.toBuffer()], - lamports: 1, - data: [ - 2, - ...testToken.token.toBuffer(), - ...initialOwner.publicKey.toBuffer(), - 123, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - ], - executable: false, - }, - }, - ]); - - // mock Token.transfer() transaction - mockSendTransaction(); - mockGetSignatureStatus(); - } - - await testToken.transfer(initialOwner, initialOwnerTokenAccount, dest, 123); - - { - // mock Token.accountInfo()'s getAccountInfo - mockRpc.push([ - url, - { - method: 'getAccountInfo', - params: [dest.toBase58()], - }, - { - error: null, - result: { - owner: [...SYSTEM_TOKEN_PROGRAM_ID.toBuffer()], - lamports: 1, - data: [ - 2, - ...testToken.token.toBuffer(), - ...dest.toBuffer(), - 123, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - ], - executable: false, - }, - }, - ]); - } - - await sleep(500); - - const destAccountInfo = await testToken.accountInfo(dest); - expect(destAccountInfo.amount.toNumber()).toBe(123); -}); - -test('approve/revoke', async () => { - const connection = new Connection(url); - connection._disableBlockhashCaching = mockRpcEnabled; - const delegateOwner = await newAccountWithLamports(connection); - - { - // mock SystemProgram.createAccount transaction for Token.newAccount() - mockSendTransaction(); - mockGetSignatureStatus(); - - // mock Token.newAccount() transaction - mockSendTransaction(); - mockGetSignatureStatus(); - } - const delegate = await testToken.newAccount( - delegateOwner, - initialOwnerTokenAccount, - ); - - { - // mock Token.approve() transaction - mockSendTransaction(); - mockGetSignatureStatus(); - } - - await testToken.approve( - initialOwner, - initialOwnerTokenAccount, - delegate, - 456, - ); - - { - // mock Token.accountInfo()'s getAccountInfo - mockRpc.push([ - url, - { - method: 'getAccountInfo', - params: [delegate.toBase58()], - }, - { - error: null, - result: { - owner: [...SYSTEM_TOKEN_PROGRAM_ID.toBuffer()], - lamports: 1, - data: [ - 2, - ...testToken.token.toBuffer(), - ...delegate.toBuffer(), - 200, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - ...initialOwnerTokenAccount.toBuffer(), - 200, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - ], - executable: false, - }, - }, - ]); - } - - let delegateAccountInfo = await testToken.accountInfo(delegate); - - expect(delegateAccountInfo.amount.toNumber()).toBe(456); - expect(delegateAccountInfo.originalAmount.toNumber()).toBe(456); - if (delegateAccountInfo.source === null) { - throw new Error('source should not be null'); - } else { - expect(delegateAccountInfo.source.equals(initialOwnerTokenAccount)).toBe( - true, - ); - } - - { - // mock Token.revoke() transaction - mockSendTransaction(); - mockGetSignatureStatus(); - } - - await testToken.revoke(initialOwner, initialOwnerTokenAccount, delegate); - - { - // mock Token.accountInfo()'s getAccountInfo - mockRpc.push([ - url, - { - method: 'getAccountInfo', - params: [delegate.toBase58()], - }, - { - error: null, - result: { - owner: [...SYSTEM_TOKEN_PROGRAM_ID.toBuffer()], - lamports: 1, - data: [ - 2, - ...testToken.token.toBuffer(), - ...delegate.toBuffer(), - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - ...initialOwnerTokenAccount.toBuffer(), - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - ], - executable: false, - }, - }, - ]); - } - - delegateAccountInfo = await testToken.accountInfo(delegate); - expect(delegateAccountInfo.amount.toNumber()).toBe(0); - expect(delegateAccountInfo.originalAmount.toNumber()).toBe(0); - if (delegateAccountInfo.source === null) { - throw new Error('source should not be null'); - } else { - expect(delegateAccountInfo.source.equals(initialOwnerTokenAccount)).toBe( - true, - ); - } -}); - -test('invalid approve', async () => { - if (mockRpcEnabled) { - console.log('non-live test skipped'); - return; - } - - const connection = new Connection(url); - const owner = await newAccountWithLamports(connection); - - const account1 = await testToken.newAccount(owner); - const account1Delegate = await testToken.newAccount(owner, account1); - const account2 = await testToken.newAccount(owner); - - // account2 is not a delegate account of account1 - await expect( - testToken.approve(owner, account1, account2, 123), - ).rejects.toThrow(); - - // account1Delegate is not a delegate account of account2 - await expect( - testToken.approve(owner, account2, account1Delegate, 123), - ).rejects.toThrow(); -}); - -test('fail on approve overspend', async () => { - if (mockRpcEnabled) { - console.log('non-live test skipped'); - return; - } - - const connection = new Connection(url); - const owner = await newAccountWithLamports(connection); - - const account1 = await testToken.newAccount(owner); - const account1Delegate = await testToken.newAccount(owner, account1); - const account2 = await testToken.newAccount(owner); - - await testToken.transfer( - initialOwner, - initialOwnerTokenAccount, - account1, - 10, - ); - - await testToken.approve(owner, account1, account1Delegate, 2); - - let delegateAccountInfo = await testToken.accountInfo(account1Delegate); - expect(delegateAccountInfo.amount.toNumber()).toBe(2); - expect(delegateAccountInfo.originalAmount.toNumber()).toBe(2); - - await testToken.transfer(owner, account1Delegate, account2, 1); - - delegateAccountInfo = await testToken.accountInfo(account1Delegate); - expect(delegateAccountInfo.amount.toNumber()).toBe(1); - expect(delegateAccountInfo.originalAmount.toNumber()).toBe(2); - - await testToken.transfer(owner, account1Delegate, account2, 1); - - delegateAccountInfo = await testToken.accountInfo(account1Delegate); - expect(delegateAccountInfo.amount.toNumber()).toBe(0); - expect(delegateAccountInfo.originalAmount.toNumber()).toBe(2); - - await expect( - testToken.transfer(owner, account1Delegate, account2, 1), - ).rejects.toThrow(); -}); - -test('set owner', async () => { - if (mockRpcEnabled) { - console.log('non-live test skipped'); - return; - } - - const connection = new Connection(url); - const owner = await newAccountWithLamports(connection); - const newOwner = await newAccountWithLamports(connection); - - const account = await testToken.newAccount(owner); - - await testToken.setOwner(owner, account, newOwner.publicKey); - await expect( - testToken.setOwner(owner, account, newOwner.publicKey), - ).rejects.toThrow(); - - await testToken.setOwner(newOwner, account, owner.publicKey); -});