From 5d3cd399465acb0f8f8bcf1345aa1cc1f406b099 Mon Sep 17 00:00:00 2001 From: Zelimir Fedoran Date: Tue, 27 Feb 2024 12:05:57 -0500 Subject: [PATCH 1/5] adding fees, split out keys package --- package-lock.json | 58 ++- packages/elements/src/index.ts | 4 +- packages/keys/README.md | 48 ++- packages/keys/package.json | 41 ++ packages/keys/src/errors.ts | 5 + packages/keys/src/index.ts | 3 + .../{library/src/keys => keys/src}/keypair.ts | 0 .../src/keys => keys/src}/publickey.ts | 2 +- .../{library => keys}/test/keypair.test.ts | 0 .../{library => keys}/test/publickey.test.ts | 0 packages/keys/tsconfig.cjs.json | 7 + packages/keys/tsconfig.json | 27 ++ packages/library/package.json | 2 +- packages/library/src/elements/options.ts | 18 + packages/library/src/idempotency.ts | 2 +- packages/library/src/index.ts | 1 - packages/library/src/intent.ts | 2 +- .../library/src/intents/LoginRequestIntent.ts | 6 +- .../src/intents/PaymentRequestIntent.ts | 6 +- .../intents/PaymentRequestWithLoginIntent.ts | 21 +- packages/library/src/keys/index.ts | 2 - packages/library/src/kin.ts | 2 +- packages/library/src/rendezvous.ts | 2 +- packages/mnemonic/package.json | 4 +- packages/mnemonic/src/derive.ts | 2 +- packages/mnemonic/src/phrase.ts | 2 +- packages/rpc/package.json | 2 +- .../account/v1/account_service_connect.ts | 16 +- .../account/v1/account_service_pb.ts | 146 ++++++- .../src/generated/chat/v1/chat_service_pb.ts | 9 +- .../rpc/src/generated/common/v1/model_pb.ts | 84 +++- .../messaging/v1/messaging_service_pb.ts | 14 +- .../v2/transaction_service_connect.ts | 21 +- .../transaction/v2/transaction_service_pb.ts | 385 ++++++++++++++++-- .../user/v1/identity_service_connect.ts | 13 +- .../generated/user/v1/identity_service_pb.ts | 155 ++++++- .../src/components/sdk/CodeDesktopModal.vue | 2 +- 37 files changed, 1008 insertions(+), 106 deletions(-) create mode 100644 packages/keys/package.json create mode 100644 packages/keys/src/errors.ts create mode 100644 packages/keys/src/index.ts rename packages/{library/src/keys => keys/src}/keypair.ts (100%) rename packages/{library/src/keys => keys/src}/publickey.ts (98%) rename packages/{library => keys}/test/keypair.test.ts (100%) rename packages/{library => keys}/test/publickey.test.ts (100%) create mode 100644 packages/keys/tsconfig.cjs.json create mode 100644 packages/keys/tsconfig.json delete mode 100644 packages/library/src/keys/index.ts diff --git a/package-lock.json b/package-lock.json index c7e98cb..6f4d9bb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "code-sdk", + "name": "code-sdk-new", "lockfileVersion": 2, "requires": true, "packages": { @@ -877,6 +877,10 @@ "resolved": "packages/flags", "link": true }, + "node_modules/@code-wallet/keys": { + "resolved": "packages/keys", + "link": true + }, "node_modules/@code-wallet/kikcode": { "resolved": "packages/kikcode", "link": true @@ -7992,7 +7996,7 @@ }, "packages/flags": { "name": "@code-wallet/flags", - "version": "1.0.0", + "version": "1.0.1", "license": "MIT", "dependencies": { "@code-wallet/library": "^1.3.4" @@ -8008,6 +8012,27 @@ "typescript": "^5.1.6" } }, + "packages/keys": { + "name": "@code-wallet/keys", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "@noble/curves": "^1.2.0", + "@noble/hashes": "^1.3.0", + "bs58": "^5.0.0", + "buffer": "6.0.3" + }, + "devDependencies": { + "@types/chai": "^4.3.5", + "@types/mocha": "^10.0.1", + "@types/node": "^20.5.7", + "chai": "^4.3.8", + "esm": "^3.2.25", + "ts-mocha": "^10.0.0", + "ts-node": "^10.9.1", + "typescript": "^5.1.6" + } + }, "packages/kikcode": { "name": "@code-wallet/kikcode", "version": "1.0.1", @@ -8028,8 +8053,8 @@ "version": "1.3.4", "license": "MIT", "dependencies": { + "@code-wallet/keys": "^1.0.0", "@code-wallet/rpc": "^1.3.1", - "@noble/curves": "^1.2.0", "@noble/hashes": "^1.3.0", "bs58": "^5.0.0", "buffer": "6.0.3" @@ -8047,10 +8072,10 @@ }, "packages/mnemonic": { "name": "@code-wallet/mnemonic", - "version": "1.0.5", + "version": "1.0.6", "license": "MIT", "dependencies": { - "@code-wallet/library": "^1.0.0", + "@code-wallet/keys": "^1.0.0", "@noble/curves": "^1.2.0", "@noble/hashes": "^1.3.0", "bs58": "^5.0.0", @@ -8170,7 +8195,7 @@ }, "packages/rpc": { "name": "@code-wallet/rpc", - "version": "1.3.1", + "version": "1.3.2", "license": "MIT", "dependencies": { "@bufbuild/connect": "^0.8.6", @@ -9008,6 +9033,23 @@ "typescript": "^5.1.6" } }, + "@code-wallet/keys": { + "version": "file:packages/keys", + "requires": { + "@noble/curves": "^1.2.0", + "@noble/hashes": "^1.3.0", + "@types/chai": "^4.3.5", + "@types/mocha": "^10.0.1", + "@types/node": "^20.5.7", + "bs58": "^5.0.0", + "buffer": "6.0.3", + "chai": "^4.3.8", + "esm": "^3.2.25", + "ts-mocha": "^10.0.0", + "ts-node": "^10.9.1", + "typescript": "^5.1.6" + } + }, "@code-wallet/kikcode": { "version": "file:packages/kikcode", "requires": { @@ -9024,8 +9066,8 @@ "@code-wallet/library": { "version": "file:packages/library", "requires": { + "@code-wallet/keys": "^1.0.0", "@code-wallet/rpc": "^1.3.1", - "@noble/curves": "^1.2.0", "@noble/hashes": "^1.3.0", "@types/chai": "^4.3.5", "@types/mocha": "^10.0.1", @@ -9042,7 +9084,7 @@ "@code-wallet/mnemonic": { "version": "file:packages/mnemonic", "requires": { - "@code-wallet/library": "^1.0.0", + "@code-wallet/keys": "^1.0.0", "@noble/curves": "^1.2.0", "@noble/hashes": "^1.3.0", "@types/chai": "^4.3.5", diff --git a/packages/elements/src/index.ts b/packages/elements/src/index.ts index 6fca48e..cfbb882 100644 --- a/packages/elements/src/index.ts +++ b/packages/elements/src/index.ts @@ -8,5 +8,5 @@ const opt: Options = { initConfig(opt); -export default { elements, errors } -export { elements, errors } \ No newline at end of file +export { elements, errors } +export default { elements, errors } \ No newline at end of file diff --git a/packages/keys/README.md b/packages/keys/README.md index c06ad4c..2987396 100644 --- a/packages/keys/README.md +++ b/packages/keys/README.md @@ -1 +1,47 @@ -@code-wallet/keys +[![npm][npm-image]][npm-url] +[![npm-downloads][npm-downloads-image]][npm-url] + +[npm-downloads-image]: https://img.shields.io/npm/dt/@code-wallet/keys?style=flat +[npm-image]: https://img.shields.io/npm/v/@code-wallet/keys?style=flat +[npm-url]: https://www.npmjs.com/package/@code-wallet/keys + +# @code-wallet/keys +Manage ED25519 cryptographic keys, including public keys and key pairs, crucial for the security and verification mechanisms of the platform. This package is part of the Code SDK, a collection of packages that provide a comprehensive set of tools for developers to integrate Code into their websites and applications. + +If you're looking for key phrases, check out the `@code-wallet/mnemonic` package. + +Learn more about Code at https://getcode.com. See the [docs](https://code-wallet.github.io/code-sdk/docs) for more information. + +## Quick Start + +```bash +npm install @code-wallet/keys +``` + +## Examples +Generating a Keypair + +```typescript +import { Keypair } from '@code-wallet/keys'; + +const keypair = Keypair.generate(); +console.log("Public value:", keypair.getPublicValue()); +console.log("Private value:", keypair.getPrivateValue()); +// console.log("Signature:", keypair.sign(...)); + +const pubkey = keypair.getPublicKey(); +console.log("Public key:", pubkey.toBase58()); + +const address = PublicKey.fromBase58("kinXdEcpDQeHPEuQnqmUgtYykqKGVFq6CeVX5iAHJq6"); +// console.log("Address:", address.verify(...)); +``` + +## Getting Started +As an internal package, `@code-wallet/keys` is tailored for developers within +the Code team. For detailed information on each module and its functionalities, +please refer to the [documentation](https://code-wallet.github.io/code-sdk). + +## Need Help? +If you have any questions or need help integrating Code into your website or +application, please reach out to us on [Discord](https://discord.gg/T8Tpj8DBFp) or +[Twitter](https://twitter.com/getcode). diff --git a/packages/keys/package.json b/packages/keys/package.json new file mode 100644 index 0000000..057667e --- /dev/null +++ b/packages/keys/package.json @@ -0,0 +1,41 @@ +{ + "name": "@code-wallet/keys", + "version": "1.0.0", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/code-payments/code-sdk.git" + }, + "source": "src/index.ts", + "main": "dist/cjs/index.js", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", + "files": [ + "./dist/" + ], + "scripts": { + "test": "TS_NODE_COMPILER_OPTIONS='{ \"module\": \"commonjs\", \"target\": \"es2019\" }' ts-mocha --require esm './test/**/*.test.ts'", + "clean": "rm -rf ./dist", + "build": "npm run clean && tsc && tsc -p tsconfig.cjs.json" + }, + "browserslist": [ + "supports bigint and not dead", + "maintained node versions" + ], + "dependencies": { + "@noble/curves": "^1.2.0", + "@noble/hashes": "^1.3.0", + "bs58": "^5.0.0", + "buffer": "6.0.3" + }, + "devDependencies": { + "@types/chai": "^4.3.5", + "@types/mocha": "^10.0.1", + "@types/node": "^20.5.7", + "chai": "^4.3.8", + "ts-mocha": "^10.0.0", + "ts-node": "^10.9.1", + "typescript": "^5.1.6", + "esm": "^3.2.25" + } +} \ No newline at end of file diff --git a/packages/keys/src/errors.ts b/packages/keys/src/errors.ts new file mode 100644 index 0000000..8ad8a49 --- /dev/null +++ b/packages/keys/src/errors.ts @@ -0,0 +1,5 @@ +const ErrInvalidAddress = () => new Error("invalid address"); + +export { + ErrInvalidAddress, +}; diff --git a/packages/keys/src/index.ts b/packages/keys/src/index.ts new file mode 100644 index 0000000..34b5b89 --- /dev/null +++ b/packages/keys/src/index.ts @@ -0,0 +1,3 @@ +export * from './errors'; +export * from './keypair'; +export * from './publickey'; \ No newline at end of file diff --git a/packages/library/src/keys/keypair.ts b/packages/keys/src/keypair.ts similarity index 100% rename from packages/library/src/keys/keypair.ts rename to packages/keys/src/keypair.ts diff --git a/packages/library/src/keys/publickey.ts b/packages/keys/src/publickey.ts similarity index 98% rename from packages/library/src/keys/publickey.ts rename to packages/keys/src/publickey.ts index 5d8b56f..c986424 100644 --- a/packages/library/src/keys/publickey.ts +++ b/packages/keys/src/publickey.ts @@ -1,7 +1,7 @@ import bs58 from "bs58"; import { Buffer } from "buffer"; import { ed25519 } from '@noble/curves/ed25519'; -import { ErrInvalidAddress } from "../errors"; +import { ErrInvalidAddress } from "./errors"; const ED25519_PUBLIC_KEY_LENGTH = 32; // Length of ED25519 public key in bytes const BASE_58_ALPHABET = /^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]+$/; diff --git a/packages/library/test/keypair.test.ts b/packages/keys/test/keypair.test.ts similarity index 100% rename from packages/library/test/keypair.test.ts rename to packages/keys/test/keypair.test.ts diff --git a/packages/library/test/publickey.test.ts b/packages/keys/test/publickey.test.ts similarity index 100% rename from packages/library/test/publickey.test.ts rename to packages/keys/test/publickey.test.ts diff --git a/packages/keys/tsconfig.cjs.json b/packages/keys/tsconfig.cjs.json new file mode 100644 index 0000000..989af8e --- /dev/null +++ b/packages/keys/tsconfig.cjs.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "CommonJS", + "outDir": "dist/cjs" + } +} \ No newline at end of file diff --git a/packages/keys/tsconfig.json b/packages/keys/tsconfig.json new file mode 100644 index 0000000..92dca72 --- /dev/null +++ b/packages/keys/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "composite": false, + "declaration": true, + "declarationMap": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "inlineSources": false, + "isolatedModules": true, + "moduleResolution": "node", + "noFallthroughCasesInSwitch": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "preserveWatchOutput": true, + "skipLibCheck": true, + "strict": true, + "target": "ES2020", + "module": "ESNext", + "outDir": "dist/esm", + }, + "include": [ + "src" + ], + "exclude": [ + "node_modules" + ] +} \ No newline at end of file diff --git a/packages/library/package.json b/packages/library/package.json index 5835884..c51b5da 100644 --- a/packages/library/package.json +++ b/packages/library/package.json @@ -24,7 +24,7 @@ ], "dependencies": { "@code-wallet/rpc": "^1.3.1", - "@noble/curves": "^1.2.0", + "@code-wallet/keys": "^1.0.0", "@noble/hashes": "^1.3.0", "bs58": "^5.0.0", "buffer": "6.0.3" diff --git a/packages/library/src/elements/options.ts b/packages/library/src/elements/options.ts index 121601a..7a28b66 100644 --- a/packages/library/src/elements/options.ts +++ b/packages/library/src/elements/options.ts @@ -17,6 +17,17 @@ type ElementAppearance = 'dark' | 'light'; */ type ElementLocale = string; +/** + * Defines a fee payment for a payment request. + */ +interface PaymentRequestFee { + /** The destination token address as a base58 string for this fee. */ + destination: string; + + /** Fee percentage, in basis point (0 - 10,000), of the total quark amount of a payment. */ + basisPoints: number; +} + /** * Defines the options needed for processing a payment request. */ @@ -29,6 +40,13 @@ interface PaymentRequestOptions { /** The currency code of the requested payment amount. */ currency: CurrencyCode; + + /** + * Additional fee payments (optional). This allows a payment request to send + * a percentage of the payment to another account. This is in addition to + * the hard-coded Code $0.01 USD fee. + * */ + fees?: PaymentRequestFee[]; } /** diff --git a/packages/library/src/idempotency.ts b/packages/library/src/idempotency.ts index e93549c..7d5f4f5 100644 --- a/packages/library/src/idempotency.ts +++ b/packages/library/src/idempotency.ts @@ -1,6 +1,6 @@ import bs58 from 'bs58'; import { sha256 } from '@noble/hashes/sha256'; -import { Keypair } from './keys'; +import { Keypair } from '@code-wallet/keys'; import { ErrInvalidSize } from './errors'; /** diff --git a/packages/library/src/index.ts b/packages/library/src/index.ts index 6c19187..48c141a 100644 --- a/packages/library/src/index.ts +++ b/packages/library/src/index.ts @@ -2,7 +2,6 @@ export * from './intent'; export * from './intents'; export * from './idempotency'; export * from './elements'; -export * from './keys'; export * from './errors'; export * from './currency'; export * from './kin'; diff --git a/packages/library/src/intent.ts b/packages/library/src/intent.ts index 0b14a36..4278543 100644 --- a/packages/library/src/intent.ts +++ b/packages/library/src/intent.ts @@ -1,7 +1,7 @@ import * as proto from '@code-wallet/rpc'; +import { Keypair } from '@code-wallet/keys'; import { IdempotencyKey } from './idempotency'; import { ElementOptions } from './elements/options'; -import { Keypair } from './keys'; import { CodePayload } from './payload'; export type IntentType = 'payment' | 'login'; diff --git a/packages/library/src/intents/LoginRequestIntent.ts b/packages/library/src/intents/LoginRequestIntent.ts index 704b7ff..de41826 100644 --- a/packages/library/src/intents/LoginRequestIntent.ts +++ b/packages/library/src/intents/LoginRequestIntent.ts @@ -1,5 +1,5 @@ import * as proto from '@code-wallet/rpc'; -import { Keypair, PublicKey } from '../keys'; +import { Keypair, PublicKey } from '@code-wallet/keys'; import { CodePayload, CodeKind } from '../payload'; import { SignedIntent } from '../intent'; import { @@ -9,7 +9,7 @@ import { ErrUnexpectedError } from '../errors'; import { validateElementOptions } from '../elements/validate'; -import { ElementOptions } from '../elements/options'; +import { ElementOptions, LoginRequestOptions } from '../elements/options'; import { AbstractIntent } from './AbstractIntent'; /** @@ -25,7 +25,7 @@ class LoginRequestIntent extends AbstractIntent { * * @param opt - The payment request options. */ - constructor(opt: ElementOptions) { + constructor(opt: LoginRequestOptions & ElementOptions) { super({ ...opt, mode: 'login', diff --git a/packages/library/src/intents/PaymentRequestIntent.ts b/packages/library/src/intents/PaymentRequestIntent.ts index b2f5240..487e541 100644 --- a/packages/library/src/intents/PaymentRequestIntent.ts +++ b/packages/library/src/intents/PaymentRequestIntent.ts @@ -1,6 +1,6 @@ import * as proto from '@code-wallet/rpc'; +import { PublicKey } from '@code-wallet/keys'; import { CurrencyCode } from '../currency'; -import { PublicKey } from '../keys'; import { CodePayload, CodeKind } from '../payload'; import { SignedIntent } from '../intent'; import { @@ -10,7 +10,7 @@ import { ErrUnexpectedError } from '../errors'; import { validateElementOptions } from '../elements/validate'; -import { ElementOptions } from '../elements/options'; +import { ElementOptions, PaymentRequestOptions } from '../elements/options'; import { Kin } from '../kin'; import { AbstractIntent } from './AbstractIntent'; @@ -26,7 +26,7 @@ class PaymentRequestIntent extends AbstractIntent { * * @param opt - The payment request options. */ - constructor(opt: ElementOptions) { + constructor(opt: PaymentRequestOptions & ElementOptions) { super({ ...opt, diff --git a/packages/library/src/intents/PaymentRequestWithLoginIntent.ts b/packages/library/src/intents/PaymentRequestWithLoginIntent.ts index 4123f56..752e276 100644 --- a/packages/library/src/intents/PaymentRequestWithLoginIntent.ts +++ b/packages/library/src/intents/PaymentRequestWithLoginIntent.ts @@ -1,5 +1,5 @@ import * as proto from '@code-wallet/rpc'; -import { Keypair, PublicKey } from '../keys'; +import { Keypair, PublicKey } from '@code-wallet/keys'; import { SignedIntent } from '../intent'; import { ErrLoginDomainRequired, @@ -7,7 +7,11 @@ import { ErrLoginVerifierRequired, ErrUnexpectedError } from '../errors'; -import { ElementOptions } from '../elements/options'; +import { + ElementOptions, + LoginRequestOptions, + PaymentRequestOptions +} from '../elements/options'; import { PaymentRequestIntent } from './PaymentRequestIntent'; /** @@ -23,7 +27,7 @@ class PaymentRequestWithLoginIntent extends PaymentRequestIntent { * * @param opt - The payment request options. */ - constructor(opt: ElementOptions) { + constructor(opt: PaymentRequestOptions & LoginRequestOptions & ElementOptions) { super(opt); const { signers } = opt; @@ -82,6 +86,17 @@ class PaymentRequestWithLoginIntent extends PaymentRequestIntent { value: this.rendezvousKeypair.getPublicKey().toBuffer(), }); + if (this.options.fees) { + req.additionalFees = this.options.fees.map((f) => { + return new proto.AdditionalFeePayment({ + destination: new proto.Common.SolanaAccountId({ + value: PublicKey.fromBase58(f.destination).toBuffer(), + }), + feeBps: f.basisPoints, + }); + }); + } + return new proto.Message({ kind: { case: 'requestToReceiveBill', diff --git a/packages/library/src/keys/index.ts b/packages/library/src/keys/index.ts deleted file mode 100644 index fcaa752..0000000 --- a/packages/library/src/keys/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './publickey'; -export * from './keypair'; \ No newline at end of file diff --git a/packages/library/src/kin.ts b/packages/library/src/kin.ts index 2d3ea2c..8e32a78 100644 --- a/packages/library/src/kin.ts +++ b/packages/library/src/kin.ts @@ -1,4 +1,4 @@ -import { PublicKey } from './keys'; +import { PublicKey } from '@code-wallet/keys'; /** * Represents the Kin cryptocurrency with operations to handle whole and fractional units. diff --git a/packages/library/src/rendezvous.ts b/packages/library/src/rendezvous.ts index 9cc4737..356f431 100644 --- a/packages/library/src/rendezvous.ts +++ b/packages/library/src/rendezvous.ts @@ -1,5 +1,5 @@ import { sha256 } from '@noble/hashes/sha256'; -import { Keypair } from './keys'; +import { Keypair } from '@code-wallet/keys'; import { CodePayload } from './payload'; /** diff --git a/packages/mnemonic/package.json b/packages/mnemonic/package.json index 337365c..c2eb7ec 100644 --- a/packages/mnemonic/package.json +++ b/packages/mnemonic/package.json @@ -1,6 +1,6 @@ { "name": "@code-wallet/mnemonic", - "version": "1.0.5", + "version": "1.0.6", "license": "MIT", "repository": { "type": "git", @@ -23,7 +23,7 @@ "maintained node versions" ], "dependencies": { - "@code-wallet/library": "^1.0.0", + "@code-wallet/keys": "^1.0.0", "@noble/curves": "^1.2.0", "@noble/hashes": "^1.3.0", "bs58": "^5.0.0", diff --git a/packages/mnemonic/src/derive.ts b/packages/mnemonic/src/derive.ts index 28c66b8..ebbe212 100644 --- a/packages/mnemonic/src/derive.ts +++ b/packages/mnemonic/src/derive.ts @@ -2,7 +2,7 @@ import { Buffer } from 'buffer'; import { pbkdf2 } from '@noble/hashes/pbkdf2'; import { sha512 } from '@noble/hashes/sha512'; import { hmac } from '@noble/hashes/hmac'; -import { Keypair } from '@code-wallet/library'; +import { Keypair } from '@code-wallet/keys'; import { Path } from './path'; import { Offset } from './offset'; diff --git a/packages/mnemonic/src/phrase.ts b/packages/mnemonic/src/phrase.ts index 924967f..744b993 100644 --- a/packages/mnemonic/src/phrase.ts +++ b/packages/mnemonic/src/phrase.ts @@ -1,5 +1,5 @@ import { randomBytes } from '@noble/hashes/utils'; -import { Keypair } from '@code-wallet/library'; +import { Keypair } from '@code-wallet/keys'; import { Path } from "./path"; import { Derive } from "./derive"; import { Mnemonic, MnemonicType } from "./mnemonic"; diff --git a/packages/rpc/package.json b/packages/rpc/package.json index 233c647..4f3a221 100644 --- a/packages/rpc/package.json +++ b/packages/rpc/package.json @@ -1,6 +1,6 @@ { "name": "@code-wallet/rpc", - "version": "1.3.1", + "version": "1.3.2", "license": "MIT", "repository": { "type": "git", diff --git a/packages/rpc/src/generated/account/v1/account_service_connect.ts b/packages/rpc/src/generated/account/v1/account_service_connect.ts index ac87ea9..6d8aaaa 100644 --- a/packages/rpc/src/generated/account/v1/account_service_connect.ts +++ b/packages/rpc/src/generated/account/v1/account_service_connect.ts @@ -3,7 +3,7 @@ /* eslint-disable */ // @ts-nocheck -import { GetTokenAccountInfosRequest, GetTokenAccountInfosResponse, IsCodeAccountRequest, IsCodeAccountResponse } from "./account_service_pb"; +import { GetTokenAccountInfosRequest, GetTokenAccountInfosResponse, IsCodeAccountRequest, IsCodeAccountResponse, LinkAdditionalAccountsRequest, LinkAdditionalAccountsResponse } from "./account_service_pb"; import { MethodKind } from "@bufbuild/protobuf"; /** @@ -37,6 +37,20 @@ export const Account = { O: GetTokenAccountInfosResponse, kind: MethodKind.Unary, }, + /** + * LinkAdditionalAccounts allows a client to declare additional accounts to + * be tracked and used within Code. The accounts declared in this RPC are not + * managed by Code (ie. not a Timelock account), created externally and cannot + * be linked automatically (ie. authority derived off user 12 words). + * + * @generated from rpc code.account.v1.Account.LinkAdditionalAccounts + */ + linkAdditionalAccounts: { + name: "LinkAdditionalAccounts", + I: LinkAdditionalAccountsRequest, + O: LinkAdditionalAccountsResponse, + kind: MethodKind.Unary, + }, } } as const; diff --git a/packages/rpc/src/generated/account/v1/account_service_pb.ts b/packages/rpc/src/generated/account/v1/account_service_pb.ts index 15ff697..99166ca 100644 --- a/packages/rpc/src/generated/account/v1/account_service_pb.ts +++ b/packages/rpc/src/generated/account/v1/account_service_pb.ts @@ -239,6 +239,136 @@ proto3.util.setEnumType(GetTokenAccountInfosResponse_Result, "code.account.v1.Ge { no: 1, name: "NOT_FOUND" }, ]); +/** + * @generated from message code.account.v1.LinkAdditionalAccountsRequest + */ +export class LinkAdditionalAccountsRequest extends Message { + /** + * The owner account to link to + * + * @generated from field: code.common.v1.SolanaAccountId owner = 1; + */ + owner?: SolanaAccountId; + + /** + * The authority account derived off the user's 12 words, which contains + * the USDC ATA (and potentially others in the future) that will be used + * in swaps. + * + * @generated from field: code.common.v1.SolanaAccountId swap_authority = 2; + */ + swapAuthority?: SolanaAccountId; + + /** + * Signature values for each account provided in this request. Each signature + * must be generated without this array set. The expected ordering of signatures: + * 1. owner + * 2. swap_authority + * + * @generated from field: repeated code.common.v1.Signature signatures = 3; + */ + signatures: Signature[] = []; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "code.account.v1.LinkAdditionalAccountsRequest"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "owner", kind: "message", T: SolanaAccountId }, + { no: 2, name: "swap_authority", kind: "message", T: SolanaAccountId }, + { no: 3, name: "signatures", kind: "message", T: Signature, repeated: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): LinkAdditionalAccountsRequest { + return new LinkAdditionalAccountsRequest().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): LinkAdditionalAccountsRequest { + return new LinkAdditionalAccountsRequest().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): LinkAdditionalAccountsRequest { + return new LinkAdditionalAccountsRequest().fromJsonString(jsonString, options); + } + + static equals(a: LinkAdditionalAccountsRequest | PlainMessage | undefined, b: LinkAdditionalAccountsRequest | PlainMessage | undefined): boolean { + return proto3.util.equals(LinkAdditionalAccountsRequest, a, b); + } +} + +/** + * @generated from message code.account.v1.LinkAdditionalAccountsResponse + */ +export class LinkAdditionalAccountsResponse extends Message { + /** + * @generated from field: code.account.v1.LinkAdditionalAccountsResponse.Result result = 1; + */ + result = LinkAdditionalAccountsResponse_Result.OK; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "code.account.v1.LinkAdditionalAccountsResponse"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "result", kind: "enum", T: proto3.getEnumType(LinkAdditionalAccountsResponse_Result) }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): LinkAdditionalAccountsResponse { + return new LinkAdditionalAccountsResponse().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): LinkAdditionalAccountsResponse { + return new LinkAdditionalAccountsResponse().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): LinkAdditionalAccountsResponse { + return new LinkAdditionalAccountsResponse().fromJsonString(jsonString, options); + } + + static equals(a: LinkAdditionalAccountsResponse | PlainMessage | undefined, b: LinkAdditionalAccountsResponse | PlainMessage | undefined): boolean { + return proto3.util.equals(LinkAdditionalAccountsResponse, a, b); + } +} + +/** + * @generated from enum code.account.v1.LinkAdditionalAccountsResponse.Result + */ +export enum LinkAdditionalAccountsResponse_Result { + /** + * Supports idempotency, and will be returned as long as the request exactly + * matches a previous execution. + * + * @generated from enum value: OK = 0; + */ + OK = 0, + + /** + * The action has been denied (eg. owner account not phone verified) + * + * @generated from enum value: DENIED = 1; + */ + DENIED = 1, + + /** + * An account being linked is not valid + * + * @generated from enum value: INVALID_ACCOUNT = 2; + */ + INVALID_ACCOUNT = 2, +} +// Retrieve enum metadata with: proto3.getEnumType(LinkAdditionalAccountsResponse_Result) +proto3.util.setEnumType(LinkAdditionalAccountsResponse_Result, "code.account.v1.LinkAdditionalAccountsResponse.Result", [ + { no: 0, name: "OK" }, + { no: 1, name: "DENIED" }, + { no: 2, name: "INVALID_ACCOUNT" }, +]); + /** * @generated from message code.account.v1.TokenAccountInfo */ @@ -352,20 +482,6 @@ export class TokenAccountInfo extends Message { */ mint?: SolanaAccountId; - /** - * The number of decimals configured for the mint - * - * @generated from field: uint32 mint_decimals = 14; - */ - mintDecimals = 0; - - /** - * User-friendly display name for the mint - * - * @generated from field: string mint_display_name = 15; - */ - mintDisplayName = ""; - /** * The relationship with a third party that this account has established with. * This only applies to relevant account types (eg. RELATIONSHIP). @@ -395,8 +511,6 @@ export class TokenAccountInfo extends Message { { no: 11, name: "claim_state", kind: "enum", T: proto3.getEnumType(TokenAccountInfo_ClaimState) }, { no: 12, name: "original_exchange_data", kind: "message", T: ExchangeData }, { no: 13, name: "mint", kind: "message", T: SolanaAccountId }, - { no: 14, name: "mint_decimals", kind: "scalar", T: 13 /* ScalarType.UINT32 */ }, - { no: 15, name: "mint_display_name", kind: "scalar", T: 9 /* ScalarType.STRING */ }, { no: 16, name: "relationship", kind: "message", T: Relationship }, ]); diff --git a/packages/rpc/src/generated/chat/v1/chat_service_pb.ts b/packages/rpc/src/generated/chat/v1/chat_service_pb.ts index b39f3a8..0e2cc72 100644 --- a/packages/rpc/src/generated/chat/v1/chat_service_pb.ts +++ b/packages/rpc/src/generated/chat/v1/chat_service_pb.ts @@ -1043,9 +1043,12 @@ export class Content extends Message { */ export class LocalizedContent extends Message { /** - * @generated from field: string key = 1; + * When server-side localization is in place, clients will always see the + * localized text. + * + * @generated from field: string key_or_text = 1; */ - key = ""; + keyOrText = ""; constructor(data?: PartialMessage) { super(); @@ -1055,7 +1058,7 @@ export class LocalizedContent extends Message { static readonly runtime: typeof proto3 = proto3; static readonly typeName = "code.chat.v1.LocalizedContent"; static readonly fields: FieldList = proto3.util.newFieldList(() => [ - { no: 1, name: "key", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 1, name: "key_or_text", kind: "scalar", T: 9 /* ScalarType.STRING */ }, ]); static fromBinary(bytes: Uint8Array, options?: Partial): LocalizedContent { diff --git a/packages/rpc/src/generated/common/v1/model_pb.ts b/packages/rpc/src/generated/common/v1/model_pb.ts index 55f9b7f..a73e784 100644 --- a/packages/rpc/src/generated/common/v1/model_pb.ts +++ b/packages/rpc/src/generated/common/v1/model_pb.ts @@ -84,9 +84,9 @@ export enum AccountType { RELATIONSHIP = 13, /** - * @generated from enum value: ASSOCIATED_TOKEN_ACCOUNT = 14; + * @generated from enum value: SWAP = 14; */ - ASSOCIATED_TOKEN_ACCOUNT = 14, + SWAP = 14, } // Retrieve enum metadata with: proto3.getEnumType(AccountType) proto3.util.setEnumType(AccountType, "code.common.v1.AccountType", [ @@ -104,7 +104,7 @@ proto3.util.setEnumType(AccountType, "code.common.v1.AccountType", [ { no: 11, name: "LEGACY_PRIMARY_2022" }, { no: 12, name: "REMOTE_SEND_GIFT_CARD" }, { no: 13, name: "RELATIONSHIP" }, - { no: 14, name: "ASSOCIATED_TOKEN_ACCOUNT" }, + { no: 14, name: "SWAP" }, ]); /** @@ -683,6 +683,84 @@ export class Hash extends Message { } } +/** + * Locale is a user locale consisting of a combination of language, script and region + * + * @generated from message code.common.v1.Locale + */ +export class Locale extends Message { + /** + * @generated from field: string value = 1; + */ + value = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "code.common.v1.Locale"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "value", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): Locale { + return new Locale().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): Locale { + return new Locale().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): Locale { + return new Locale().fromJsonString(jsonString, options); + } + + static equals(a: Locale | PlainMessage | undefined, b: Locale | PlainMessage | undefined): boolean { + return proto3.util.equals(Locale, a, b); + } +} + +/** + * UUID is a 16 byte UUID value + * + * @generated from message code.common.v1.UUID + */ +export class UUID extends Message { + /** + * @generated from field: bytes value = 1; + */ + value = new Uint8Array(0); + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "code.common.v1.UUID"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "value", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): UUID { + return new UUID().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): UUID { + return new UUID().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): UUID { + return new UUID().fromJsonString(jsonString, options); + } + + static equals(a: UUID | PlainMessage | undefined, b: UUID | PlainMessage | undefined): boolean { + return proto3.util.equals(UUID, a, b); + } +} + /** * Request is a generic wrapper for gRPC requests * diff --git a/packages/rpc/src/generated/messaging/v1/messaging_service_pb.ts b/packages/rpc/src/generated/messaging/v1/messaging_service_pb.ts index 45ecae4..47e427e 100644 --- a/packages/rpc/src/generated/messaging/v1/messaging_service_pb.ts +++ b/packages/rpc/src/generated/messaging/v1/messaging_service_pb.ts @@ -6,7 +6,7 @@ import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; import { Duration, Message as Message$1, proto3, Timestamp } from "@bufbuild/protobuf"; import { Domain, IntentId, Signature, SolanaAccountId } from "../../common/v1/model_pb"; -import { AirdropType, ExchangeData, ExchangeDataWithoutRate, Metadata } from "../../transaction/v2/transaction_service_pb"; +import { AdditionalFeePayment, AirdropType, ExchangeData, ExchangeDataWithoutRate, Metadata } from "../../transaction/v2/transaction_service_pb"; /** * @generated from message code.messaging.v1.OpenMessageStreamRequest @@ -688,6 +688,14 @@ export class RequestToReceiveBill extends Message$1 { */ rendezvousKey?: RendezvousKey; + /** + * Additional fee payments splitting the requested amount. This is in addition + * to the hard-coded Code $0.01 USD fee. + * + * @generated from field: repeated code.transaction.v2.AdditionalFeePayment additional_fees = 8; + */ + additionalFees: AdditionalFeePayment[] = []; + constructor(data?: PartialMessage) { super(); proto3.util.initPartial(data, this); @@ -703,6 +711,7 @@ export class RequestToReceiveBill extends Message$1 { { no: 5, name: "verifier", kind: "message", T: SolanaAccountId }, { no: 6, name: "signature", kind: "message", T: Signature }, { no: 7, name: "rendezvous_key", kind: "message", T: RendezvousKey }, + { no: 8, name: "additional_fees", kind: "message", T: AdditionalFeePayment, repeated: true }, ]); static fromBinary(bytes: Uint8Array, options?: Partial): RequestToReceiveBill { @@ -821,6 +830,9 @@ export class IntentSubmitted extends Message$1 { intentId?: IntentId; /** + * Metadata is available for intents where it can be safely propagated publicly. + * Anything else requires an additional authenticated RPC call (eg. login). + * * @generated from field: code.transaction.v2.Metadata metadata = 2; */ metadata?: Metadata; diff --git a/packages/rpc/src/generated/transaction/v2/transaction_service_connect.ts b/packages/rpc/src/generated/transaction/v2/transaction_service_connect.ts index 1badebb..c27f9b5 100644 --- a/packages/rpc/src/generated/transaction/v2/transaction_service_connect.ts +++ b/packages/rpc/src/generated/transaction/v2/transaction_service_connect.ts @@ -3,7 +3,7 @@ /* eslint-disable */ // @ts-nocheck -import { AirdropRequest, AirdropResponse, CanWithdrawToAccountRequest, CanWithdrawToAccountResponse, GetIntentMetadataRequest, GetIntentMetadataResponse, GetLimitsRequest, GetLimitsResponse, GetPaymentHistoryRequest, GetPaymentHistoryResponse, GetPrioritizedIntentsForPrivacyUpgradeRequest, GetPrioritizedIntentsForPrivacyUpgradeResponse, GetPrivacyUpgradeStatusRequest, GetPrivacyUpgradeStatusResponse, SubmitIntentRequest, SubmitIntentResponse, SwapRequest, SwapResponse } from "./transaction_service_pb"; +import { AirdropRequest, AirdropResponse, CanWithdrawToAccountRequest, CanWithdrawToAccountResponse, DeclareFiatOnrampPurchaseAttemptRequest, DeclareFiatOnrampPurchaseAttemptResponse, GetIntentMetadataRequest, GetIntentMetadataResponse, GetLimitsRequest, GetLimitsResponse, GetPaymentHistoryRequest, GetPaymentHistoryResponse, GetPrioritizedIntentsForPrivacyUpgradeRequest, GetPrioritizedIntentsForPrivacyUpgradeResponse, GetPrivacyUpgradeStatusRequest, GetPrivacyUpgradeStatusResponse, SubmitIntentRequest, SubmitIntentResponse, SwapRequest, SwapResponse } from "./transaction_service_pb"; import { MethodKind } from "@bufbuild/protobuf"; /** @@ -149,6 +149,13 @@ export const Transaction = { * * Balance changes are applied after the transaction has finalized * * Transactions use recent blockhashes over a nonce * + * The transaction will have the following instruction format: + * 1. ComputeBudget::SetComputeUnitLimit + * 2. ComputeBudget::SetComputeUnitPrice + * 3. SwapValidator::PreSwap + * 4. Dynamic swap instruction + * 5. SwapValidator::PostSwap + * * Note: Currently limited to swapping USDC to Kin. * Note: Kin is deposited into the primary account. * @@ -160,6 +167,18 @@ export const Transaction = { O: SwapResponse, kind: MethodKind.BiDiStreaming, }, + /** + * DeclareFiatOnrampPurchaseAttempt is called whenever a user attempts to use a fiat + * onramp to purchase crypto for use in Code. + * + * @generated from rpc code.transaction.v2.Transaction.DeclareFiatOnrampPurchaseAttempt + */ + declareFiatOnrampPurchaseAttempt: { + name: "DeclareFiatOnrampPurchaseAttempt", + I: DeclareFiatOnrampPurchaseAttemptRequest, + O: DeclareFiatOnrampPurchaseAttemptResponse, + kind: MethodKind.Unary, + }, } } as const; diff --git a/packages/rpc/src/generated/transaction/v2/transaction_service_pb.ts b/packages/rpc/src/generated/transaction/v2/transaction_service_pb.ts index b7f699f..3fe7ca7 100644 --- a/packages/rpc/src/generated/transaction/v2/transaction_service_pb.ts +++ b/packages/rpc/src/generated/transaction/v2/transaction_service_pb.ts @@ -5,7 +5,7 @@ import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; import { Message, proto3, protoInt64, Timestamp } from "@bufbuild/protobuf"; -import { AccountType, Blockhash, DeviceToken, Hash, InstructionAccount, IntentId, Relationship, Signature, SolanaAccountId, Transaction } from "../../common/v1/model_pb"; +import { AccountType, Blockhash, DeviceToken, Hash, InstructionAccount, IntentId, Relationship, Signature, SolanaAccountId, Transaction, UUID } from "../../common/v1/model_pb"; /** * @generated from enum code.transaction.v2.AirdropType @@ -932,11 +932,11 @@ export class GetLimitsResponse extends Message { result = GetLimitsResponse_Result.OK; /** - * Remaining send limits keyed by currency + * Send limits keyed by currency * - * @generated from field: map remaining_send_limits_by_currency = 2; + * @generated from field: map send_limits_by_currency = 2; */ - remainingSendLimitsByCurrency: { [key: string]: RemainingSendLimit } = {}; + sendLimitsByCurrency: { [key: string]: SendLimit } = {}; /** * Deposit limits @@ -952,6 +952,13 @@ export class GetLimitsResponse extends Message { */ microPaymentLimitsByCurrency: { [key: string]: MicroPaymentLimit } = {}; + /** + * Buy module limits keyed by currency + * + * @generated from field: map buy_module_limits_by_currency = 5; + */ + buyModuleLimitsByCurrency: { [key: string]: BuyModuleLimit } = {}; + constructor(data?: PartialMessage) { super(); proto3.util.initPartial(data, this); @@ -961,9 +968,10 @@ export class GetLimitsResponse extends Message { static readonly typeName = "code.transaction.v2.GetLimitsResponse"; static readonly fields: FieldList = proto3.util.newFieldList(() => [ { no: 1, name: "result", kind: "enum", T: proto3.getEnumType(GetLimitsResponse_Result) }, - { no: 2, name: "remaining_send_limits_by_currency", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: RemainingSendLimit} }, + { no: 2, name: "send_limits_by_currency", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: SendLimit} }, { no: 3, name: "deposit_limit", kind: "message", T: DepositLimit }, { no: 4, name: "micro_payment_limits_by_currency", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: MicroPaymentLimit} }, + { no: 5, name: "buy_module_limits_by_currency", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: BuyModuleLimit} }, ]); static fromBinary(bytes: Uint8Array, options?: Partial): GetLimitsResponse { @@ -1598,10 +1606,10 @@ export class SwapResponse extends Message { */ response: { /** - * @generated from field: code.transaction.v2.SwapResponse.ServerParameters server_paramenters = 1; + * @generated from field: code.transaction.v2.SwapResponse.ServerParameters server_parameters = 1; */ value: SwapResponse_ServerParameters; - case: "serverParamenters"; + case: "serverParameters"; } | { /** * @generated from field: code.transaction.v2.SwapResponse.Success success = 2; @@ -1624,7 +1632,7 @@ export class SwapResponse extends Message { static readonly runtime: typeof proto3 = proto3; static readonly typeName = "code.transaction.v2.SwapResponse"; static readonly fields: FieldList = proto3.util.newFieldList(() => [ - { no: 1, name: "server_paramenters", kind: "message", T: SwapResponse_ServerParameters, oneof: "response" }, + { no: 1, name: "server_parameters", kind: "message", T: SwapResponse_ServerParameters, oneof: "response" }, { no: 2, name: "success", kind: "message", T: SwapResponse_Success, oneof: "response" }, { no: 3, name: "error", kind: "message", T: SwapResponse_Error, oneof: "response" }, ]); @@ -1668,9 +1676,9 @@ export class SwapResponse_ServerParameters extends Message [ { no: 1, name: "payer", kind: "message", T: SolanaAccountId }, { no: 2, name: "recent_blockhash", kind: "message", T: Blockhash }, - { no: 3, name: "compute_unit_limit", kind: "scalar", T: 4 /* ScalarType.UINT64 */ }, + { no: 3, name: "compute_unit_limit", kind: "scalar", T: 13 /* ScalarType.UINT32 */ }, { no: 4, name: "compute_unit_price", kind: "scalar", T: 4 /* ScalarType.UINT64 */ }, { no: 5, name: "swap_program", kind: "message", T: SolanaAccountId }, { no: 6, name: "swap_ixn_accounts", kind: "message", T: InstructionAccount, repeated: true }, @@ -1886,11 +1894,11 @@ export enum SwapResponse_Error_Code { SIGNATURE_ERROR = 2, /** - * An amount to swap to/from is invalid + * The swap failed server-side validation * - * @generated from enum value: INVALID_SWAP_AMOUNT = 3; + * @generated from enum value: INVALID_SWAP = 3; */ - INVALID_SWAP_AMOUNT = 3, + INVALID_SWAP = 3, /** * The submitted swap transaction failed. Attempt the swap again. @@ -1903,10 +1911,152 @@ export enum SwapResponse_Error_Code { proto3.util.setEnumType(SwapResponse_Error_Code, "code.transaction.v2.SwapResponse.Error.Code", [ { no: 0, name: "DENIED" }, { no: 2, name: "SIGNATURE_ERROR" }, - { no: 3, name: "INVALID_SWAP_AMOUNT" }, + { no: 3, name: "INVALID_SWAP" }, { no: 4, name: "SWAP_FAILED" }, ]); +/** + * @generated from message code.transaction.v2.DeclareFiatOnrampPurchaseAttemptRequest + */ +export class DeclareFiatOnrampPurchaseAttemptRequest extends Message { + /** + * The owner account invoking the buy module + * + * @generated from field: code.common.v1.SolanaAccountId owner = 1; + */ + owner?: SolanaAccountId; + + /** + * The amount being purchased + * + * @generated from field: code.transaction.v2.ExchangeDataWithoutRate purchase_amount = 2; + */ + purchaseAmount?: ExchangeDataWithoutRate; + + /** + * A nonce value unique to the purchase. If it's included in a memo for the + * transaction for the deposit to the owner, then purchase_amount will be used + * for display values. Otherwise, the amount will be inferred from the transaction. + * + * @generated from field: code.common.v1.UUID nonce = 3; + */ + nonce?: UUID; + + /** + * The signature is of serialize(DeclareFiatOnrampPurchaseAttemptRequest) without + * this field set using the private key of the owner account. This provides an + * authentication mechanism to the RPC. + * + * @generated from field: code.common.v1.Signature signature = 4; + */ + signature?: Signature; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "code.transaction.v2.DeclareFiatOnrampPurchaseAttemptRequest"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "owner", kind: "message", T: SolanaAccountId }, + { no: 2, name: "purchase_amount", kind: "message", T: ExchangeDataWithoutRate }, + { no: 3, name: "nonce", kind: "message", T: UUID }, + { no: 4, name: "signature", kind: "message", T: Signature }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): DeclareFiatOnrampPurchaseAttemptRequest { + return new DeclareFiatOnrampPurchaseAttemptRequest().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): DeclareFiatOnrampPurchaseAttemptRequest { + return new DeclareFiatOnrampPurchaseAttemptRequest().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): DeclareFiatOnrampPurchaseAttemptRequest { + return new DeclareFiatOnrampPurchaseAttemptRequest().fromJsonString(jsonString, options); + } + + static equals(a: DeclareFiatOnrampPurchaseAttemptRequest | PlainMessage | undefined, b: DeclareFiatOnrampPurchaseAttemptRequest | PlainMessage | undefined): boolean { + return proto3.util.equals(DeclareFiatOnrampPurchaseAttemptRequest, a, b); + } +} + +/** + * @generated from message code.transaction.v2.DeclareFiatOnrampPurchaseAttemptResponse + */ +export class DeclareFiatOnrampPurchaseAttemptResponse extends Message { + /** + * @generated from field: code.transaction.v2.DeclareFiatOnrampPurchaseAttemptResponse.Result result = 1; + */ + result = DeclareFiatOnrampPurchaseAttemptResponse_Result.OK; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "code.transaction.v2.DeclareFiatOnrampPurchaseAttemptResponse"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "result", kind: "enum", T: proto3.getEnumType(DeclareFiatOnrampPurchaseAttemptResponse_Result) }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): DeclareFiatOnrampPurchaseAttemptResponse { + return new DeclareFiatOnrampPurchaseAttemptResponse().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): DeclareFiatOnrampPurchaseAttemptResponse { + return new DeclareFiatOnrampPurchaseAttemptResponse().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): DeclareFiatOnrampPurchaseAttemptResponse { + return new DeclareFiatOnrampPurchaseAttemptResponse().fromJsonString(jsonString, options); + } + + static equals(a: DeclareFiatOnrampPurchaseAttemptResponse | PlainMessage | undefined, b: DeclareFiatOnrampPurchaseAttemptResponse | PlainMessage | undefined): boolean { + return proto3.util.equals(DeclareFiatOnrampPurchaseAttemptResponse, a, b); + } +} + +/** + * @generated from enum code.transaction.v2.DeclareFiatOnrampPurchaseAttemptResponse.Result + */ +export enum DeclareFiatOnrampPurchaseAttemptResponse_Result { + /** + * @generated from enum value: OK = 0; + */ + OK = 0, + + /** + * The owner account is not valid (ie. it isn't a Code account) + * + * @generated from enum value: INVALID_OWNER = 1; + */ + INVALID_OWNER = 1, + + /** + * The currency isn't supported + * + * @generated from enum value: UNSUPPORTED_CURRENCY = 2; + */ + UNSUPPORTED_CURRENCY = 2, + + /** + * The amount specified exceeds limits + * + * @generated from enum value: AMOUNT_EXCEEDS_MAXIMUM = 3; + */ + AMOUNT_EXCEEDS_MAXIMUM = 3, +} +// Retrieve enum metadata with: proto3.getEnumType(DeclareFiatOnrampPurchaseAttemptResponse_Result) +proto3.util.setEnumType(DeclareFiatOnrampPurchaseAttemptResponse_Result, "code.transaction.v2.DeclareFiatOnrampPurchaseAttemptResponse.Result", [ + { no: 0, name: "OK" }, + { no: 1, name: "INVALID_OWNER" }, + { no: 2, name: "UNSUPPORTED_CURRENCY" }, + { no: 3, name: "AMOUNT_EXCEEDS_MAXIMUM" }, +]); + /** * Metadata describes the high-level details of an intent * @@ -2105,11 +2255,20 @@ export class OpenAccountsMetadata extends Message { * TemporaryPrivacyExchangeAction(BUCKET_X_KIN, BUCKET_X_KIN, multiple * bucketSize), * TemporaryPrivacyTransferAction(BUCKET_X_KIN, TEMPORARY_OUTGOING[index], multiple * bucketSize), * - * // Section 2: Rotate TEMPORARY_OUTGOING account + * // Section 2: Fee payments + * + * // Hard-coded Code $0.01 USD fee to a dynamic fee account + * FeePayment(TEMPORARY_OUTGOING[index], codeFeeAccount, $0.01 USD of Kin), + * + * // Additional fees, exactly as specified in the original payment request + * FeePayment(TEMPORARY_OUTGOING[index], additionalFeeAccount0, additionalFeeQuarks0), + * ... + * FeePayment(TEMPORARY_OUTGOING[index], additionalFeeAccountN, additionalFeeQuarksN), + * + * // Section 3: Rotate TEMPORARY_OUTGOING account * * // Below must appear last in this exact order - * FeePayment(TEMPORARY_OUTGOING[index], feeAccount, $0.01 USD of Kin), - * NoPrivacyWithdrawAction(TEMPORARY_OUTGOING[index], destination, ExchangeData.Quarks - $0.01 USD of Kin), + * NoPrivacyWithdrawAction(TEMPORARY_OUTGOING[index], destination, ExchangeData.Quarks - $0.01 USD of Kin - additionalFeeQuarks0 - ... - additionalFeeQuarksN), * OpenAccountAction(TEMPORARY_OUTGOING[index + 1]), * CloseDormantAccount(TEMPORARY_OUTGOING[index + 1]), * ] @@ -3270,14 +3429,19 @@ export class PermanentPrivacyUpgradeAction extends Message fee account) * Client Signature Required: Yes * - * Note: This is exactly a NoPrivacyTransferAction, except the destination - * account is controlled by Code and provided in a server parameter. - * Note: The fee amount is hardcoded at the client and validated by server. - * Currently, its set to $0.01 USD. + * Note: This is exactly a NoPrivacyTransferAction, but with specialized metadata + * for fees. * * @generated from message code.transaction.v2.FeePaymentAction */ export class FeePaymentAction extends Message { + /** + * The type of fee being operated on + * + * @generated from field: code.transaction.v2.FeePaymentAction.FeeType type = 4; + */ + type = FeePaymentAction_FeeType.CODE; + /** * The public key of the private key that has authority over source * @@ -3299,6 +3463,14 @@ export class FeePaymentAction extends Message { */ amount = protoInt64.zero; + /** + * The destination where the fee payment is being made for fees outside of + * Code. + * + * @generated from field: code.common.v1.SolanaAccountId destination = 5; + */ + destination?: SolanaAccountId; + constructor(data?: PartialMessage) { super(); proto3.util.initPartial(data, this); @@ -3307,9 +3479,11 @@ export class FeePaymentAction extends Message { static readonly runtime: typeof proto3 = proto3; static readonly typeName = "code.transaction.v2.FeePaymentAction"; static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 4, name: "type", kind: "enum", T: proto3.getEnumType(FeePaymentAction_FeeType) }, { no: 1, name: "authority", kind: "message", T: SolanaAccountId }, { no: 2, name: "source", kind: "message", T: SolanaAccountId }, { no: 3, name: "amount", kind: "scalar", T: 4 /* ScalarType.UINT64 */ }, + { no: 5, name: "destination", kind: "message", T: SolanaAccountId }, ]); static fromBinary(bytes: Uint8Array, options?: Partial): FeePaymentAction { @@ -3329,6 +3503,30 @@ export class FeePaymentAction extends Message { } } +/** + * @generated from enum code.transaction.v2.FeePaymentAction.FeeType + */ +export enum FeePaymentAction_FeeType { + /** + * Hardcoded $0.01 USD fee to a dynamic fee account specified by server + * + * @generated from enum value: CODE = 0; + */ + CODE = 0, + + /** + * Third party fee specified at time of payment request + * + * @generated from enum value: THIRD_PARTY = 1; + */ + THIRD_PARTY = 1, +} +// Retrieve enum metadata with: proto3.getEnumType(FeePaymentAction_FeeType) +proto3.util.setEnumType(FeePaymentAction_FeeType, "code.transaction.v2.FeePaymentAction.FeeType", [ + { no: 0, name: "CODE" }, + { no: 1, name: "THIRD_PARTY" }, +]); + /** * ServerParameter are a set of parameters known and returned by server that * enables clients to complete transaction construction. Any necessary proofs, @@ -3846,11 +4044,12 @@ export class PermanentPrivacyUpgradeServerParameter extends Message { /** - * The destination account where the fee payment should be sent. + * The destination account where Code fee payments should be sent. This will + * only be set when the corresponding FeePaymentAction Type is CODE. * - * @generated from field: code.common.v1.SolanaAccountId destination = 1; + * @generated from field: code.common.v1.SolanaAccountId code_destination = 1; */ - destination?: SolanaAccountId; + codeDestination?: SolanaAccountId; constructor(data?: PartialMessage) { super(); @@ -3860,7 +4059,7 @@ export class FeePaymentServerParameter extends Message [ - { no: 1, name: "destination", kind: "message", T: SolanaAccountId }, + { no: 1, name: "code_destination", kind: "message", T: SolanaAccountId }, ]); static fromBinary(bytes: Uint8Array, options?: Partial): FeePaymentServerParameter { @@ -4451,9 +4650,56 @@ export class ExchangeDataWithoutRate extends Message { } /** - * @generated from message code.transaction.v2.RemainingSendLimit + * @generated from message code.transaction.v2.AdditionalFeePayment */ -export class RemainingSendLimit extends Message { +export class AdditionalFeePayment extends Message { + /** + * Destination Kin token account where the fee payment will be made + * + * @generated from field: code.common.v1.SolanaAccountId destination = 1; + */ + destination?: SolanaAccountId; + + /** + * Fee percentage, in basis points, of the total quark amount of a payment. + * + * @generated from field: uint32 fee_bps = 2; + */ + feeBps = 0; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "code.transaction.v2.AdditionalFeePayment"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "destination", kind: "message", T: SolanaAccountId }, + { no: 2, name: "fee_bps", kind: "scalar", T: 13 /* ScalarType.UINT32 */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): AdditionalFeePayment { + return new AdditionalFeePayment().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): AdditionalFeePayment { + return new AdditionalFeePayment().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): AdditionalFeePayment { + return new AdditionalFeePayment().fromJsonString(jsonString, options); + } + + static equals(a: AdditionalFeePayment | PlainMessage | undefined, b: AdditionalFeePayment | PlainMessage | undefined): boolean { + return proto3.util.equals(AdditionalFeePayment, a, b); + } +} + +/** + * @generated from message code.transaction.v2.SendLimit + */ +export class SendLimit extends Message { /** * Remaining limit to apply on the next transaction * @@ -4461,31 +4707,47 @@ export class RemainingSendLimit extends Message { */ nextTransaction = 0; - constructor(data?: PartialMessage) { + /** + * Maximum allowed on a per-transaction basis + * + * @generated from field: float max_per_transaction = 2; + */ + maxPerTransaction = 0; + + /** + * Maximum allowed on a per-day basis + * + * @generated from field: float max_per_day = 3; + */ + maxPerDay = 0; + + constructor(data?: PartialMessage) { super(); proto3.util.initPartial(data, this); } static readonly runtime: typeof proto3 = proto3; - static readonly typeName = "code.transaction.v2.RemainingSendLimit"; + static readonly typeName = "code.transaction.v2.SendLimit"; static readonly fields: FieldList = proto3.util.newFieldList(() => [ { no: 1, name: "next_transaction", kind: "scalar", T: 2 /* ScalarType.FLOAT */ }, + { no: 2, name: "max_per_transaction", kind: "scalar", T: 2 /* ScalarType.FLOAT */ }, + { no: 3, name: "max_per_day", kind: "scalar", T: 2 /* ScalarType.FLOAT */ }, ]); - static fromBinary(bytes: Uint8Array, options?: Partial): RemainingSendLimit { - return new RemainingSendLimit().fromBinary(bytes, options); + static fromBinary(bytes: Uint8Array, options?: Partial): SendLimit { + return new SendLimit().fromBinary(bytes, options); } - static fromJson(jsonValue: JsonValue, options?: Partial): RemainingSendLimit { - return new RemainingSendLimit().fromJson(jsonValue, options); + static fromJson(jsonValue: JsonValue, options?: Partial): SendLimit { + return new SendLimit().fromJson(jsonValue, options); } - static fromJsonString(jsonString: string, options?: Partial): RemainingSendLimit { - return new RemainingSendLimit().fromJsonString(jsonString, options); + static fromJsonString(jsonString: string, options?: Partial): SendLimit { + return new SendLimit().fromJsonString(jsonString, options); } - static equals(a: RemainingSendLimit | PlainMessage | undefined, b: RemainingSendLimit | PlainMessage | undefined): boolean { - return proto3.util.equals(RemainingSendLimit, a, b); + static equals(a: SendLimit | PlainMessage | undefined, b: SendLimit | PlainMessage | undefined): boolean { + return proto3.util.equals(SendLimit, a, b); } } @@ -4578,6 +4840,53 @@ export class MicroPaymentLimit extends Message { } } +/** + * @generated from message code.transaction.v2.BuyModuleLimit + */ +export class BuyModuleLimit extends Message { + /** + * Minimum amount that can be purchased through the buy module + * + * @generated from field: float min_per_transaction = 1; + */ + minPerTransaction = 0; + + /** + * Maximum amount that can be purchased through the buy module + * + * @generated from field: float max_per_transaction = 2; + */ + maxPerTransaction = 0; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "code.transaction.v2.BuyModuleLimit"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "min_per_transaction", kind: "scalar", T: 2 /* ScalarType.FLOAT */ }, + { no: 2, name: "max_per_transaction", kind: "scalar", T: 2 /* ScalarType.FLOAT */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): BuyModuleLimit { + return new BuyModuleLimit().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): BuyModuleLimit { + return new BuyModuleLimit().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): BuyModuleLimit { + return new BuyModuleLimit().fromJsonString(jsonString, options); + } + + static equals(a: BuyModuleLimit | PlainMessage | undefined, b: BuyModuleLimit | PlainMessage | undefined): boolean { + return proto3.util.equals(BuyModuleLimit, a, b); + } +} + /** * @generated from message code.transaction.v2.Cursor */ diff --git a/packages/rpc/src/generated/user/v1/identity_service_connect.ts b/packages/rpc/src/generated/user/v1/identity_service_connect.ts index fcf2507..80a8c50 100644 --- a/packages/rpc/src/generated/user/v1/identity_service_connect.ts +++ b/packages/rpc/src/generated/user/v1/identity_service_connect.ts @@ -3,7 +3,7 @@ /* eslint-disable */ // @ts-nocheck -import { GetLoginForThirdPartyAppRequest, GetLoginForThirdPartyAppResponse, GetUserRequest, GetUserResponse, LinkAccountRequest, LinkAccountResponse, LoginToThirdPartyAppRequest, LoginToThirdPartyAppResponse, UnlinkAccountRequest, UnlinkAccountResponse } from "./identity_service_pb"; +import { GetLoginForThirdPartyAppRequest, GetLoginForThirdPartyAppResponse, GetUserRequest, GetUserResponse, LinkAccountRequest, LinkAccountResponse, LoginToThirdPartyAppRequest, LoginToThirdPartyAppResponse, UnlinkAccountRequest, UnlinkAccountResponse, UpdatePreferencesRequest, UpdatePreferencesResponse } from "./identity_service_pb"; import { MethodKind } from "@bufbuild/protobuf"; /** @@ -66,6 +66,17 @@ export const Identity = { O: GetUserResponse, kind: MethodKind.Unary, }, + /** + * UpdatePreferences updates user preferences. + * + * @generated from rpc code.user.v1.Identity.UpdatePreferences + */ + updatePreferences: { + name: "UpdatePreferences", + I: UpdatePreferencesRequest, + O: UpdatePreferencesResponse, + kind: MethodKind.Unary, + }, /** * LoginToThirdPartyApp logs a user into a third party app for a given intent * ID. If the original request requires payment, then SubmitIntent must be called. diff --git a/packages/rpc/src/generated/user/v1/identity_service_pb.ts b/packages/rpc/src/generated/user/v1/identity_service_pb.ts index 93ff17b..f22ad5b 100644 --- a/packages/rpc/src/generated/user/v1/identity_service_pb.ts +++ b/packages/rpc/src/generated/user/v1/identity_service_pb.ts @@ -5,7 +5,7 @@ import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; import { Message, proto3 } from "@bufbuild/protobuf"; -import { DataContainerId, IntentId, PhoneNumber, Signature, SolanaAccountId, UserId } from "../../common/v1/model_pb"; +import { DataContainerId, IntentId, Locale, PhoneNumber, Signature, SolanaAccountId, UserId } from "../../common/v1/model_pb"; import { PhoneLinkingToken } from "../../phone/v1/phone_verification_service_pb"; import { AirdropType } from "../../transaction/v2/transaction_service_pb"; @@ -486,6 +486,135 @@ proto3.util.setEnumType(GetUserResponse_Result, "code.user.v1.GetUserResponse.Re { no: 3, name: "UNLOCKED_TIMELOCK_ACCOUNT" }, ]); +/** + * @generated from message code.user.v1.UpdatePreferencesRequest + */ +export class UpdatePreferencesRequest extends Message { + /** + * The public key of the owner account that signed this request message. + * + * @generated from field: code.common.v1.SolanaAccountId owner_account_id = 1; + */ + ownerAccountId?: SolanaAccountId; + + /** + * The data container for the copy of the contact list being added to. + * + * @generated from field: code.common.v1.DataContainerId container_id = 2; + */ + containerId?: DataContainerId; + + /** + * The signature is of serialize(UpdatePreferencesRequest) without this field set + * using the private key of owner_account_id. + * + * @generated from field: code.common.v1.Signature signature = 3; + */ + signature?: Signature; + + /** + * The user's locale, which is used for server-side localization of things like + * chat messages, pushes, etc. If no locale is set, or the provided locale isn't + * supported, then English is used as the default fallback. + * + * Note: This is required since it's the only preference. In the future, we'll add + * optional fields, where the subset of fields provided will be the ones that + * are updated. + * + * @generated from field: code.common.v1.Locale locale = 4; + */ + locale?: Locale; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "code.user.v1.UpdatePreferencesRequest"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "owner_account_id", kind: "message", T: SolanaAccountId }, + { no: 2, name: "container_id", kind: "message", T: DataContainerId }, + { no: 3, name: "signature", kind: "message", T: Signature }, + { no: 4, name: "locale", kind: "message", T: Locale }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): UpdatePreferencesRequest { + return new UpdatePreferencesRequest().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): UpdatePreferencesRequest { + return new UpdatePreferencesRequest().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): UpdatePreferencesRequest { + return new UpdatePreferencesRequest().fromJsonString(jsonString, options); + } + + static equals(a: UpdatePreferencesRequest | PlainMessage | undefined, b: UpdatePreferencesRequest | PlainMessage | undefined): boolean { + return proto3.util.equals(UpdatePreferencesRequest, a, b); + } +} + +/** + * @generated from message code.user.v1.UpdatePreferencesResponse + */ +export class UpdatePreferencesResponse extends Message { + /** + * @generated from field: code.user.v1.UpdatePreferencesResponse.Result result = 1; + */ + result = UpdatePreferencesResponse_Result.OK; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "code.user.v1.UpdatePreferencesResponse"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "result", kind: "enum", T: proto3.getEnumType(UpdatePreferencesResponse_Result) }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): UpdatePreferencesResponse { + return new UpdatePreferencesResponse().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): UpdatePreferencesResponse { + return new UpdatePreferencesResponse().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): UpdatePreferencesResponse { + return new UpdatePreferencesResponse().fromJsonString(jsonString, options); + } + + static equals(a: UpdatePreferencesResponse | PlainMessage | undefined, b: UpdatePreferencesResponse | PlainMessage | undefined): boolean { + return proto3.util.equals(UpdatePreferencesResponse, a, b); + } +} + +/** + * @generated from enum code.user.v1.UpdatePreferencesResponse.Result + */ +export enum UpdatePreferencesResponse_Result { + /** + * @generated from enum value: OK = 0; + */ + OK = 0, + + /** + * The provided locale couldn't be parsed or recognized and is invalid. + * + * @generated from enum value: INVALID_LOCALE = 1; + */ + INVALID_LOCALE = 1, +} +// Retrieve enum metadata with: proto3.getEnumType(UpdatePreferencesResponse_Result) +proto3.util.setEnumType(UpdatePreferencesResponse_Result, "code.user.v1.UpdatePreferencesResponse.Result", [ + { no: 0, name: "OK" }, + { no: 1, name: "INVALID_LOCALE" }, +]); + /** * @generated from message code.user.v1.LoginToThirdPartyAppRequest */ @@ -505,8 +634,8 @@ export class LoginToThirdPartyAppRequest extends Message From b72034d86c14d6ed0c186eda17379a0e8e7db93a Mon Sep 17 00:00:00 2001 From: Zelimir Fedoran Date: Tue, 27 Feb 2024 16:07:26 -0500 Subject: [PATCH 2/5] added currency and intents packages, removed library package --- Makefile | 38 ++++++++ package-lock.json | 92 +++++++++++++++++- packages/client/package.json | 5 +- packages/client/src/intents/login.ts | 2 +- packages/client/src/intents/payments.ts | 4 +- packages/client/src/requests/getStatus.ts | 2 +- packages/client/src/requests/getUserId.ts | 2 +- .../client/src/requests/registerWebhook.ts | 2 +- packages/client/src/utils/createIntent.ts | 2 +- packages/client/test/client.test.ts | 2 +- packages/currency/README.md | 23 +++++ packages/currency/package.json | 38 ++++++++ packages/currency/src/errors.ts | 7 ++ packages/currency/src/index.ts | 4 + .../src => currency/src/mints}/kin.ts | 0 packages/currency/src/types.ts | 23 +++++ .../src/currency.ts => currency/src/utils.ts} | 25 +---- .../test/fiat.test.ts} | 0 .../{library => currency}/test/kin.test.ts | 0 .../{library => currency}/tsconfig.cjs.json | 0 packages/{library => currency}/tsconfig.json | 0 packages/elements/package.json | 4 +- .../elements/IntentRequestButton.vue | 2 +- .../elements/IntentRequestModalMobile.vue | 2 +- .../src/components/flows/ButtonFlow.vue | 10 +- .../PreloadIntentRequestModalDesktop.vue | 2 +- .../PreloadIntentRequestModalMobile.vue | 2 +- packages/elements/src/elements.ts | 2 +- packages/flags/package.json | 4 +- packages/flags/src/index.ts | 2 +- packages/{library => intents}/package.json | 6 +- packages/{library => intents}/src/errors.ts | 0 .../src/elements => intents/src}/events.ts | 9 +- packages/intents/src/index.ts | 7 ++ .../src/intents/AbstractIntent.ts | 13 +-- .../src/intents/LoginRequestIntent.ts | 11 ++- .../src/intents/PaymentRequestIntent.ts | 15 ++- .../intents/PaymentRequestWithLoginIntent.ts | 11 +-- .../{library => intents}/src/intents/index.ts | 0 .../src => intents/src/keys}/idempotency.ts | 2 +- packages/intents/src/keys/index.ts | 2 + .../src => intents/src/keys}/rendezvous.ts | 2 +- .../src/elements => intents/src}/options.ts | 93 +++++++++++++------ .../src/intent.ts => intents/src/types.ts} | 53 +---------- .../elements => intents/src/utils}/encode.ts | 2 +- .../elements => intents/src/utils}/index.ts | 2 - .../src/utils}/validate.ts | 40 ++++---- .../test/idempotency.test.ts | 0 .../test/intent_login_request.test.ts | 5 +- .../test/intent_payment_request.test.ts | 4 +- .../intent_payment_request_with_login.test.ts | 7 +- packages/intents/tsconfig.cjs.json | 7 ++ packages/intents/tsconfig.json | 27 ++++++ packages/kikcode/package.json | 3 +- packages/kikcode/src/errors.ts | 7 ++ packages/kikcode/src/index.ts | 3 + packages/kikcode/src/kikcode-encoding.ts | 5 +- packages/{library => kikcode}/src/payload.ts | 93 ++----------------- packages/kikcode/src/types.ts | 82 ++++++++++++++++ .../{library => kikcode}/test/payload.test.ts | 5 +- packages/library/README.md | 32 ------- packages/library/src/index.ts | 8 -- packages/utils/README.md | 1 - packages/views/package.json | 5 +- .../views/src/components/sdk/CodeButton.vue | 2 +- packages/views/src/utils/requests/login.ts | 2 +- packages/views/src/utils/requests/payment.ts | 4 +- packages/views/src/utils/requests/request.ts | 3 +- packages/web/README.md | 8 +- packages/web/package.json | 1 - packages/web/src/index.ts | 3 +- 71 files changed, 551 insertions(+), 335 deletions(-) create mode 100644 Makefile create mode 100644 packages/currency/README.md create mode 100644 packages/currency/package.json create mode 100644 packages/currency/src/errors.ts create mode 100644 packages/currency/src/index.ts rename packages/{library/src => currency/src/mints}/kin.ts (100%) create mode 100644 packages/currency/src/types.ts rename packages/{library/src/currency.ts => currency/src/utils.ts} (85%) rename packages/{library/test/currency.test.ts => currency/test/fiat.test.ts} (100%) rename packages/{library => currency}/test/kin.test.ts (100%) rename packages/{library => currency}/tsconfig.cjs.json (100%) rename packages/{library => currency}/tsconfig.json (100%) rename packages/{library => intents}/package.json (88%) rename packages/{library => intents}/src/errors.ts (100%) rename packages/{library/src/elements => intents/src}/events.ts (80%) create mode 100644 packages/intents/src/index.ts rename packages/{library => intents}/src/intents/AbstractIntent.ts (87%) rename packages/{library => intents}/src/intents/LoginRequestIntent.ts (93%) rename packages/{library => intents}/src/intents/PaymentRequestIntent.ts (94%) rename packages/{library => intents}/src/intents/PaymentRequestWithLoginIntent.ts (96%) rename packages/{library => intents}/src/intents/index.ts (100%) rename packages/{library/src => intents/src/keys}/idempotency.ts (98%) create mode 100644 packages/intents/src/keys/index.ts rename packages/{library/src => intents/src/keys}/rendezvous.ts (97%) rename packages/{library/src/elements => intents/src}/options.ts (53%) rename packages/{library/src/intent.ts => intents/src/types.ts} (58%) rename packages/{library/src/elements => intents/src/utils}/encode.ts (97%) rename packages/{library/src/elements => intents/src/utils}/index.ts (50%) rename packages/{library/src/elements => intents/src/utils}/validate.ts (84%) rename packages/{library => intents}/test/idempotency.test.ts (100%) rename packages/{library => intents}/test/intent_login_request.test.ts (99%) rename packages/{library => intents}/test/intent_payment_request.test.ts (99%) rename packages/{library => intents}/test/intent_payment_request_with_login.test.ts (98%) create mode 100644 packages/intents/tsconfig.cjs.json create mode 100644 packages/intents/tsconfig.json create mode 100644 packages/kikcode/src/errors.ts rename packages/{library => kikcode}/src/payload.ts (59%) create mode 100644 packages/kikcode/src/types.ts rename packages/{library => kikcode}/test/payload.test.ts (97%) delete mode 100644 packages/library/README.md delete mode 100644 packages/library/src/index.ts delete mode 100644 packages/utils/README.md diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..46e42c2 --- /dev/null +++ b/Makefile @@ -0,0 +1,38 @@ +.PHONY: clear-cache +clear-cache: + @rm -rf ./node_modules + @rm -rf ./packages/views/node_modules/client + @rm -rf ./packages/views/node_modules/currency + @rm -rf ./packages/views/node_modules/elements + @rm -rf ./packages/views/node_modules/events + @rm -rf ./packages/views/node_modules/flags + @rm -rf ./packages/views/node_modules/intents + @rm -rf ./packages/views/node_modules/keys + @rm -rf ./packages/views/node_modules/kikcode + @rm -rf ./packages/views/node_modules/mnemonic + @rm -rf ./packages/views/node_modules/programs + @rm -rf ./packages/views/node_modules/proxy + @rm -rf ./packages/views/node_modules/rpc + @rm -rf ./packages/views/node_modules/views + @rm -rf ./packages/views/node_modules/web + +.PHONY: build-sdk +build-sdk: + npm install --workspaces + cd packages/keys && npm run build && cd ../.. + cd packages/mnemonic && npm run build && cd ../.. + cd packages/flags && npm run build && cd ../.. + cd packages/currency && npm run build && cd ../.. + cd packages/rpc && npm run build && cd ../.. + cd packages/kikcode && npm run build && cd ../.. + cd packages/programs && npm run build && cd ../.. + cd packages/intents && npm run build && cd ../.. + cd packages/events && npm run build && cd ../.. + cd packages/client && npm run build && cd ../.. + cd packages/elements && npm run build && cd ../.. + cd packages/views && npm run build && cd ../.. + cd packages/web && npm run build && cd ../.. + cd packages/proxy && npm run build && cd ../.. + +.PHONY: build +build: build-sdk \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 6f4d9bb..ae8ae3f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -865,6 +865,10 @@ "resolved": "packages/client", "link": true }, + "node_modules/@code-wallet/currency": { + "resolved": "packages/currency", + "link": true + }, "node_modules/@code-wallet/elements": { "resolved": "packages/elements", "link": true @@ -877,6 +881,10 @@ "resolved": "packages/flags", "link": true }, + "node_modules/@code-wallet/intents": { + "resolved": "packages/intents", + "link": true + }, "node_modules/@code-wallet/keys": { "resolved": "packages/keys", "link": true @@ -7952,6 +7960,24 @@ "typescript": "^5.1.6" } }, + "packages/currency": { + "name": "@code-wallet/currency", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "@code-wallet/keys": "^1.0.0" + }, + "devDependencies": { + "@types/chai": "^4.3.5", + "@types/mocha": "^10.0.1", + "@types/node": "^20.5.7", + "chai": "^4.3.8", + "esm": "^3.2.25", + "ts-mocha": "^10.0.0", + "ts-node": "^10.9.1", + "typescript": "^5.1.6" + } + }, "packages/elements": { "name": "@code-wallet/elements", "version": "2.0.1", @@ -8012,6 +8038,30 @@ "typescript": "^5.1.6" } }, + "packages/intents": { + "name": "@code-wallet/intents", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "@code-wallet/currency": "^1.0.0", + "@code-wallet/keys": "^1.0.0", + "@code-wallet/kikcode": "^1.0.0", + "@code-wallet/rpc": "^1.3.1", + "@noble/hashes": "^1.3.0", + "bs58": "^5.0.0", + "buffer": "6.0.3" + }, + "devDependencies": { + "@types/chai": "^4.3.5", + "@types/mocha": "^10.0.1", + "@types/node": "^20.5.7", + "chai": "^4.3.8", + "esm": "^3.2.25", + "ts-mocha": "^10.0.0", + "ts-node": "^10.9.1", + "typescript": "^5.1.6" + } + }, "packages/keys": { "name": "@code-wallet/keys", "version": "1.0.0", @@ -8035,8 +8085,11 @@ }, "packages/kikcode": { "name": "@code-wallet/kikcode", - "version": "1.0.1", + "version": "1.0.2", "license": "MIT", + "dependencies": { + "@code-wallet/currency": "^1.0.0" + }, "devDependencies": { "@types/chai": "^4.3.5", "@types/mocha": "^10.0.1", @@ -8053,6 +8106,7 @@ "version": "1.3.4", "license": "MIT", "dependencies": { + "@code-wallet/currency": "^1.0.0", "@code-wallet/keys": "^1.0.0", "@code-wallet/rpc": "^1.3.1", "@noble/hashes": "^1.3.0", @@ -8982,6 +9036,20 @@ "typescript": "^5.1.6" } }, + "@code-wallet/currency": { + "version": "file:packages/currency", + "requires": { + "@code-wallet/keys": "^1.0.0", + "@types/chai": "^4.3.5", + "@types/mocha": "^10.0.1", + "@types/node": "^20.5.7", + "chai": "^4.3.8", + "esm": "^3.2.25", + "ts-mocha": "^10.0.0", + "ts-node": "^10.9.1", + "typescript": "^5.1.6" + } + }, "@code-wallet/elements": { "version": "file:packages/elements", "requires": { @@ -9033,6 +9101,26 @@ "typescript": "^5.1.6" } }, + "@code-wallet/intents": { + "version": "file:packages/intents", + "requires": { + "@code-wallet/currency": "^1.0.0", + "@code-wallet/keys": "^1.0.0", + "@code-wallet/kikcode": "^1.0.0", + "@code-wallet/rpc": "^1.3.1", + "@noble/hashes": "^1.3.0", + "@types/chai": "^4.3.5", + "@types/mocha": "^10.0.1", + "@types/node": "^20.5.7", + "bs58": "^5.0.0", + "buffer": "6.0.3", + "chai": "^4.3.8", + "esm": "^3.2.25", + "ts-mocha": "^10.0.0", + "ts-node": "^10.9.1", + "typescript": "^5.1.6" + } + }, "@code-wallet/keys": { "version": "file:packages/keys", "requires": { @@ -9053,6 +9141,7 @@ "@code-wallet/kikcode": { "version": "file:packages/kikcode", "requires": { + "@code-wallet/currency": "^1.0.0", "@types/chai": "^4.3.5", "@types/mocha": "^10.0.1", "@types/node": "^20.5.7", @@ -9066,6 +9155,7 @@ "@code-wallet/library": { "version": "file:packages/library", "requires": { + "@code-wallet/currency": "^1.0.0", "@code-wallet/keys": "^1.0.0", "@code-wallet/rpc": "^1.3.1", "@noble/hashes": "^1.3.0", diff --git a/packages/client/package.json b/packages/client/package.json index d81840d..df0c3ea 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@code-wallet/client", - "version": "2.0.7", + "version": "2.0.8", "license": "MIT", "repository": { "type": "git", @@ -23,7 +23,8 @@ "maintained node versions" ], "dependencies": { - "@code-wallet/library": "^1.3.2", + "@code-wallet/keys": "^1.0.0", + "@code-wallet/intents": "^1.0.0", "@code-wallet/rpc": "^1.3.1", "bs58": "^5.0.0", "buffer": "6.0.3" diff --git a/packages/client/src/intents/login.ts b/packages/client/src/intents/login.ts index 9f0f5f3..4bef647 100644 --- a/packages/client/src/intents/login.ts +++ b/packages/client/src/intents/login.ts @@ -4,7 +4,7 @@ import { LoginRequestOptions, WebhookParams, LoginRequestIntent, -} from "@code-wallet/library"; +} from "@code-wallet/intents"; import { useClient } from "../utils/useClient"; import { createIntent } from "../utils/createIntent"; diff --git a/packages/client/src/intents/payments.ts b/packages/client/src/intents/payments.ts index 3a8d4c4..f3399ac 100644 --- a/packages/client/src/intents/payments.ts +++ b/packages/client/src/intents/payments.ts @@ -7,7 +7,7 @@ import { LoginRequestOptions, WebhookParams, Intent, -} from "@code-wallet/library"; +} from "@code-wallet/intents"; import { useClient } from "../utils/useClient"; import { createIntent } from "../utils/createIntent"; @@ -52,7 +52,7 @@ const paymentIntents = { let intent : Intent; if (opt.login) { - intent = new PaymentRequestWithLoginIntent(opt); + intent = new PaymentRequestWithLoginIntent(opt as CreatePaymentIntentOptions & LoginRequestOptions); } else { intent = new PaymentRequestIntent(opt); } diff --git a/packages/client/src/requests/getStatus.ts b/packages/client/src/requests/getStatus.ts index 9d77781..0ffb3a9 100644 --- a/packages/client/src/requests/getStatus.ts +++ b/packages/client/src/requests/getStatus.ts @@ -1,5 +1,5 @@ import * as proto from "@code-wallet/rpc"; -import { PublicKey, } from "@code-wallet/library"; +import { PublicKey } from "@code-wallet/keys"; import { CodeRequest } from "../request"; import { Client } from "../client"; diff --git a/packages/client/src/requests/getUserId.ts b/packages/client/src/requests/getUserId.ts index da61241..20709c1 100644 --- a/packages/client/src/requests/getUserId.ts +++ b/packages/client/src/requests/getUserId.ts @@ -1,5 +1,5 @@ import * as proto from "@code-wallet/rpc"; -import { Keypair, PublicKey, } from "@code-wallet/library"; +import { Keypair, PublicKey, } from "@code-wallet/keys"; import { CodeRequest, } from "../request"; import { Client } from "../client"; import { ErrSignerRequired } from "../errors"; diff --git a/packages/client/src/requests/registerWebhook.ts b/packages/client/src/requests/registerWebhook.ts index 9aa60a3..8976875 100644 --- a/packages/client/src/requests/registerWebhook.ts +++ b/packages/client/src/requests/registerWebhook.ts @@ -1,5 +1,5 @@ import * as proto from "@code-wallet/rpc"; -import { PublicKey, } from "@code-wallet/library"; +import { PublicKey, } from "@code-wallet/keys"; import { CodeRequest } from "../request"; import { Client } from "../client"; diff --git a/packages/client/src/utils/createIntent.ts b/packages/client/src/utils/createIntent.ts index 8e29041..379f6b6 100644 --- a/packages/client/src/utils/createIntent.ts +++ b/packages/client/src/utils/createIntent.ts @@ -1,5 +1,5 @@ import { Client } from "../client"; -import { Intent, } from "@code-wallet/library"; +import { Intent, } from "@code-wallet/intents"; import * as proto from "@code-wallet/rpc"; import { ErrUnexpectedError } from "../errors"; diff --git a/packages/client/test/client.test.ts b/packages/client/test/client.test.ts index eef19b3..6d04e7f 100644 --- a/packages/client/test/client.test.ts +++ b/packages/client/test/client.test.ts @@ -1,8 +1,8 @@ +import { PublicKey } from "@code-wallet/keys"; import * as proto from "@code-wallet/rpc"; import * as client from "../src/"; import { Client } from "../src/"; -import { PublicKey } from "@code-wallet/library"; import { expect } from 'chai'; describe('Low level client', () => { diff --git a/packages/currency/README.md b/packages/currency/README.md new file mode 100644 index 0000000..1083ad7 --- /dev/null +++ b/packages/currency/README.md @@ -0,0 +1,23 @@ +[![npm][npm-image]][npm-url] +[![npm-downloads][npm-downloads-image]][npm-url] + +[npm-downloads-image]: https://img.shields.io/npm/dt/@code-wallet/currency?style=flat +[npm-image]: https://img.shields.io/npm/v/@code-wallet/currency?style=flat +[npm-url]: https://www.npmjs.com/package/@code-wallet/currency + +# @code-wallet/currency +Handle operations and conversions related to different currencies, with a +particular focus on the Kin cryptocurrency. This is an internal toolkit designed +to support the core functionalities of the Code SDK. + +Learn more about Code at https://getcode.com. See the [docs](https://code-wallet.github.io/code-sdk/docs) for more information. + +## Getting Started +As an internal package, `@code-wallet/currency` is tailored for developers within +the Code team. For detailed information on each module and its functionalities, +please refer to the [documentation](https://code-wallet.github.io/code-sdk). + +## Need Help? +If you have any questions or need help integrating Code into your website or +application, please reach out to us on [Discord](https://discord.gg/T8Tpj8DBFp) or +[Twitter](https://twitter.com/getcode). diff --git a/packages/currency/package.json b/packages/currency/package.json new file mode 100644 index 0000000..6580567 --- /dev/null +++ b/packages/currency/package.json @@ -0,0 +1,38 @@ +{ + "name": "@code-wallet/currency", + "version": "1.0.0", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/code-payments/code-sdk.git" + }, + "source": "src/index.ts", + "main": "dist/cjs/index.js", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", + "files": [ + "./dist/" + ], + "scripts": { + "test": "TS_NODE_COMPILER_OPTIONS='{ \"module\": \"commonjs\", \"target\": \"es2019\" }' ts-mocha --require esm './test/**/*.test.ts'", + "clean": "rm -rf ./dist", + "build": "npm run clean && tsc && tsc -p tsconfig.cjs.json" + }, + "browserslist": [ + "supports bigint and not dead", + "maintained node versions" + ], + "dependencies": { + "@code-wallet/keys": "^1.0.0" + }, + "devDependencies": { + "@types/chai": "^4.3.5", + "@types/mocha": "^10.0.1", + "@types/node": "^20.5.7", + "chai": "^4.3.8", + "ts-mocha": "^10.0.0", + "ts-node": "^10.9.1", + "typescript": "^5.1.6", + "esm": "^3.2.25" + } +} diff --git a/packages/currency/src/errors.ts b/packages/currency/src/errors.ts new file mode 100644 index 0000000..05fec61 --- /dev/null +++ b/packages/currency/src/errors.ts @@ -0,0 +1,7 @@ +const ErrCurrencyRequired = () => new Error("currency is required"); +const ErrInvalidCurrency = () => new Error("invalid currency"); + +export { + ErrCurrencyRequired, + ErrInvalidCurrency, +}; diff --git a/packages/currency/src/index.ts b/packages/currency/src/index.ts new file mode 100644 index 0000000..8f6b38d --- /dev/null +++ b/packages/currency/src/index.ts @@ -0,0 +1,4 @@ +export * from './errors'; +export * from './types'; +export * from './utils'; +export * from './mints/kin'; \ No newline at end of file diff --git a/packages/library/src/kin.ts b/packages/currency/src/mints/kin.ts similarity index 100% rename from packages/library/src/kin.ts rename to packages/currency/src/mints/kin.ts diff --git a/packages/currency/src/types.ts b/packages/currency/src/types.ts new file mode 100644 index 0000000..fe29ea6 --- /dev/null +++ b/packages/currency/src/types.ts @@ -0,0 +1,23 @@ +/** + * Represents a currency code. + */ +export type CurrencyCode = +// Crypto + "kin" | +// Fiat + "aed" | "afn" | "all" | "amd" | "ang" | "aoa" | "ars" | "aud" | "awg" | "azn" | + "bam" | "bbd" | "bdt" | "bgn" | "bhd" | "bif" | "bmd" | "bnd" | "bob" | "brl" | + "bsd" | "btn" | "bwp" | "byn" | "bzd" | "cad" | "cdf" | "chf" | "clp" | "cny" | + "cop" | "crc" | "cup" | "cve" | "czk" | "djf" | "dkk" | "dop" | "dzd" | "egp" | + "ern" | "etb" | "eur" | "fjd" | "fkp" | "gbp" | "gel" | "ghs" | "gip" | "gmd" | + "gnf" | "gtq" | "gyd" | "hkd" | "hnl" | "hrk" | "htg" | "huf" | "idr" | "ils" | + "inr" | "iqd" | "irr" | "isk" | "jmd" | "jod" | "jpy" | "kes" | "kgs" | "khr" | + "kmf" | "kpw" | "krw" | "kwd" | "kyd" | "kzt" | "lak" | "lbp" | "lkr" | "lrd" | + "lyd" | "mad" | "mdl" | "mga" | "mkd" | "mmk" | "mnt" | "mop" | "mru" | "mur" | + "mvr" | "mwk" | "mxn" | "myr" | "mzn" | "nad" | "ngn" | "nio" | "nok" | "npr" | + "nzd" | "omr" | "pab" | "pen" | "pgk" | "php" | "pkr" | "pln" | "pyg" | "qar" | + "ron" | "rsd" | "rub" | "rwf" | "sar" | "sbd" | "scr" | "sdg" | "sek" | "sgd" | + "shp" | "sll" | "sos" | "srd" | "ssp" | "stn" | "syp" | "szl" | "thb" | "tjs" | + "tmt" | "tnd" | "top" | "try" | "ttd" | "twd" | "tzs" | "uah" | "ugx" | "usd" | + "uyu" | "uzs" | "ves" | "vnd" | "vuv" | "wst" | "xaf" | "xcd" | "xof" | "xpf" | + "yer" | "zar" | "zmw"; diff --git a/packages/library/src/currency.ts b/packages/currency/src/utils.ts similarity index 85% rename from packages/library/src/currency.ts rename to packages/currency/src/utils.ts index 8ef7aeb..de29b20 100644 --- a/packages/library/src/currency.ts +++ b/packages/currency/src/utils.ts @@ -1,28 +1,5 @@ import { ErrInvalidCurrency } from "./errors"; - -/** - * Represents a currency code. - */ -export type CurrencyCode = -// Crypto - "kin" | -// Fiat - "aed" | "afn" | "all" | "amd" | "ang" | "aoa" | "ars" | "aud" | "awg" | "azn" | - "bam" | "bbd" | "bdt" | "bgn" | "bhd" | "bif" | "bmd" | "bnd" | "bob" | "brl" | - "bsd" | "btn" | "bwp" | "byn" | "bzd" | "cad" | "cdf" | "chf" | "clp" | "cny" | - "cop" | "crc" | "cup" | "cve" | "czk" | "djf" | "dkk" | "dop" | "dzd" | "egp" | - "ern" | "etb" | "eur" | "fjd" | "fkp" | "gbp" | "gel" | "ghs" | "gip" | "gmd" | - "gnf" | "gtq" | "gyd" | "hkd" | "hnl" | "hrk" | "htg" | "huf" | "idr" | "ils" | - "inr" | "iqd" | "irr" | "isk" | "jmd" | "jod" | "jpy" | "kes" | "kgs" | "khr" | - "kmf" | "kpw" | "krw" | "kwd" | "kyd" | "kzt" | "lak" | "lbp" | "lkr" | "lrd" | - "lyd" | "mad" | "mdl" | "mga" | "mkd" | "mmk" | "mnt" | "mop" | "mru" | "mur" | - "mvr" | "mwk" | "mxn" | "myr" | "mzn" | "nad" | "ngn" | "nio" | "nok" | "npr" | - "nzd" | "omr" | "pab" | "pen" | "pgk" | "php" | "pkr" | "pln" | "pyg" | "qar" | - "ron" | "rsd" | "rub" | "rwf" | "sar" | "sbd" | "scr" | "sdg" | "sek" | "sgd" | - "shp" | "sll" | "sos" | "srd" | "ssp" | "stn" | "syp" | "szl" | "thb" | "tjs" | - "tmt" | "tnd" | "top" | "try" | "ttd" | "twd" | "tzs" | "uah" | "ugx" | "usd" | - "uyu" | "uzs" | "ves" | "vnd" | "vuv" | "wst" | "xaf" | "xcd" | "xof" | "xpf" | - "yer" | "zar" | "zmw"; +import { CurrencyCode } from "./types"; /** * Index of currency codes in the lookup table. diff --git a/packages/library/test/currency.test.ts b/packages/currency/test/fiat.test.ts similarity index 100% rename from packages/library/test/currency.test.ts rename to packages/currency/test/fiat.test.ts diff --git a/packages/library/test/kin.test.ts b/packages/currency/test/kin.test.ts similarity index 100% rename from packages/library/test/kin.test.ts rename to packages/currency/test/kin.test.ts diff --git a/packages/library/tsconfig.cjs.json b/packages/currency/tsconfig.cjs.json similarity index 100% rename from packages/library/tsconfig.cjs.json rename to packages/currency/tsconfig.cjs.json diff --git a/packages/library/tsconfig.json b/packages/currency/tsconfig.json similarity index 100% rename from packages/library/tsconfig.json rename to packages/currency/tsconfig.json diff --git a/packages/elements/package.json b/packages/elements/package.json index 6e1f551..e2cabae 100644 --- a/packages/elements/package.json +++ b/packages/elements/package.json @@ -1,6 +1,6 @@ { "name": "@code-wallet/elements", - "version": "2.0.1", + "version": "2.0.2", "license": "MIT", "repository": { "type": "git", @@ -26,7 +26,7 @@ ], "dependencies": { "@code-wallet/events": "^1.4.0", - "@code-wallet/library": "^1.3.3", + "@code-wallet/intents": "^1.0.0", "@code-wallet/client": "^2.0.6", "@code-wallet/rpc": "^1.3.1", "vue": "^3.2.45" diff --git a/packages/elements/src/components/elements/IntentRequestButton.vue b/packages/elements/src/components/elements/IntentRequestButton.vue index 53c9fef..3eccadc 100644 --- a/packages/elements/src/components/elements/IntentRequestButton.vue +++ b/packages/elements/src/components/elements/IntentRequestButton.vue @@ -2,7 +2,7 @@ import { inject, onMounted, ref } from 'vue'; import { useConfig } from '../../config'; import { EventChannel, InternalButtonEvents, InternalElementEvents } from '@code-wallet/events'; - import { ElementOptions, encode } from '@code-wallet/library'; + import { ElementOptions, encode } from '@code-wallet/intents'; const config = useConfig(); const options = inject('options'); diff --git a/packages/elements/src/components/elements/IntentRequestModalMobile.vue b/packages/elements/src/components/elements/IntentRequestModalMobile.vue index 3c4dce4..c4318a8 100644 --- a/packages/elements/src/components/elements/IntentRequestModalMobile.vue +++ b/packages/elements/src/components/elements/IntentRequestModalMobile.vue @@ -1,6 +1,6 @@