Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
.PHONY: clean-cache
clean-cache:
@rm -rf ./node_modules
@rm -rf ./packages/client/node_modules
@rm -rf ./packages/currency/node_modules
@rm -rf ./packages/elements/node_modules
@rm -rf ./packages/events/node_modules
@rm -rf ./packages/flags/node_modules
@rm -rf ./packages/intents/node_modules
@rm -rf ./packages/keys/node_modules
@rm -rf ./packages/kikcode/node_modules
@rm -rf ./packages/mnemonic/node_modules
@rm -rf ./packages/programs/node_modules
@rm -rf ./packages/proxy/node_modules
@rm -rf ./packages/rpc/node_modules
@rm -rf ./packages/views/node_modules
@rm -rf ./packages/web/node_modules

.PHONY: clean-dist
clean-dist:
@rm -rf ./packages/client/dist
@rm -rf ./packages/currency/dist
@rm -rf ./packages/elements/dist
@rm -rf ./packages/events/dist
@rm -rf ./packages/flags/dist
@rm -rf ./packages/intents/dist
@rm -rf ./packages/keys/dist
@rm -rf ./packages/kikcode/dist
@rm -rf ./packages/mnemonic/dist
@rm -rf ./packages/programs/dist
@rm -rf ./packages/proxy/dist
@rm -rf ./packages/rpc/dist
@rm -rf ./packages/views/dist
@rm -rf ./packages/web/dist


.PHONY: build-sdk
build-sdk: clean-dist
npm install --workspaces
cd packages/keys && npm run build && cd ../..
cd packages/mnemonic && npm run build && cd ../..
cd packages/currency && npm run build && cd ../..
cd packages/flags && 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

.PHONY: clean
clean: clean-cache clean-dist
2 changes: 1 addition & 1 deletion examples/4-minimal-with-webhook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"license": "ISC",
"dependencies": {
"@code-wallet/client": "^2.0.7",
"@code-wallet/library": "^1.3.3",
"@code-wallet/keys": "^1.0.0",
"body-parser": "^1.20.2",
"ejs": "^3.1.9",
"express": "^4.18.2",
Expand Down
2 changes: 1 addition & 1 deletion examples/4-minimal-with-webhook/server.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import express from "express";
import bodyParser from "body-parser";
import { jwtVerify, importJWK } from 'jose';
import { PublicKey } from "@code-wallet/library";
import { PublicKey } from "@code-wallet/keys";
import * as code from "@code-wallet/client";

const port = 3030;
Expand Down
2 changes: 1 addition & 1 deletion examples/5-example-purchase-flow/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"license": "ISC",
"dependencies": {
"@code-wallet/client": "^2.0.2",
"@code-wallet/library": "^1.3.1",
"@code-wallet/currency": "^1.0.0",
"@markdoc/markdoc": "^0.3.2",
"body-parser": "^1.20.2",
"dotenv": "^16.3.1",
Expand Down
2 changes: 1 addition & 1 deletion examples/5-example-purchase-flow/src/models/articles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CurrencyCode } from '@code-wallet/library';
import { CurrencyCode } from '@code-wallet/currency';

const defaultCurrency: CurrencyCode = 'usd';
const defaultPrice = 0.25;
Expand Down
2 changes: 1 addition & 1 deletion examples/5-example-purchase-flow/src/utils/jwt.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { jwtVerify } from 'jose';
import { PublicKey } from '@code-wallet/library';
import { PublicKey } from '@code-wallet/keys';
import { createPublicKey } from 'crypto';

export async function verifyToken(token: string, publicKey: string) {
Expand Down
5,277 changes: 3,182 additions & 2,095 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions packages/client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@code-wallet/client",
"version": "2.0.7",
"version": "2.0.8",
"license": "MIT",
"repository": {
"type": "git",
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/intents/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/intents/payments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/requests/getStatus.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/requests/getUserId.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/requests/registerWebhook.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/utils/createIntent.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
2 changes: 1 addition & 1 deletion packages/client/test/client.test.ts
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down
23 changes: 23 additions & 0 deletions packages/currency/README.md
Original file line number Diff line number Diff line change
@@ -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).
38 changes: 38 additions & 0 deletions packages/currency/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
7 changes: 7 additions & 0 deletions packages/currency/src/errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const ErrCurrencyRequired = () => new Error("currency is required");
const ErrInvalidCurrency = () => new Error("invalid currency");

export {
ErrCurrencyRequired,
ErrInvalidCurrency,
};
4 changes: 4 additions & 0 deletions packages/currency/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './errors';
export * from './types';
export * from './utils';
export * from './mints/kin';
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
23 changes: 23 additions & 0 deletions packages/currency/src/types.ts
Original file line number Diff line number Diff line change
@@ -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";
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions packages/elements/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@code-wallet/elements",
"version": "2.0.1",
"version": "2.0.2",
"license": "MIT",
"repository": {
"type": "git",
Expand All @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ElementOptions>('options');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { EventChannel, InternalEvents } from '@code-wallet/events';
import { ElementOptions, encode } from '@code-wallet/library';
import { ElementOptions, encode } from '@code-wallet/intents';
import { useConfig } from '../../config';
import { inject, onMounted, ref, watchEffect } from 'vue';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { EventChannel, InternalEvents } from '@code-wallet/events';
import { ElementOptions, encode } from '@code-wallet/library';
import { ElementOptions, encode } from '@code-wallet/intents';
import { useConfig } from '../../config';
import { inject, onMounted, ref, watchEffect } from 'vue';

Expand Down
10 changes: 6 additions & 4 deletions packages/elements/src/components/flows/ButtonFlow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import {
ElementEventEmitter,
ElementOptions,
LoginRequestIntent,
PaymentRequestIntent
} from '@code-wallet/library';
LoginRequestOptions,
PaymentRequestIntent,
PaymentRequestOptions
} from '@code-wallet/intents';
import { EventChannel, InternalEvents } from '@code-wallet/events';
import * as code from "@code-wallet/client";

Expand Down Expand Up @@ -76,9 +78,9 @@ async function onInvoke() {

// Get the intent id from the receiving app or iframe
if (options.mode === 'payment') {
intent.value = new PaymentRequestIntent(options).getIntentId();
intent.value = new PaymentRequestIntent(options as ElementOptions & PaymentRequestOptions).getIntentId();
} else {
intent.value = new LoginRequestIntent(options).getIntentId();
intent.value = new LoginRequestIntent(options as ElementOptions & LoginRequestOptions).getIntentId();
}

const variables = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { ElementOptions, encode } from '@code-wallet/library';
import { ElementOptions, encode } from '@code-wallet/intents';
import { useConfig } from '../../config';
import { inject, ref } from 'vue';

Expand Down
Loading