Skip to content

Commit

Permalink
Update Keyguard client to rebased version
Browse files Browse the repository at this point in the history
  • Loading branch information
sisou committed Apr 29, 2024
1 parent 36d1a4f commit f99a7b4
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 39 deletions.
14 changes: 8 additions & 6 deletions client/dist/HubApi.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var es = {
};

var fil = {
"popup-overlay": "Nag-bukas ang isang pop-up.\nMaaring i-click kahit saan para ibalik ito sa harap."
"popup-overlay": "Nag-bukas ang isang pop-up.\nMaaring pindutin kahit saan para ibalik ito sa harap."
};

var fr = {
Expand Down Expand Up @@ -116,9 +116,9 @@ class PopupRequestBehavior extends RequestBehavior {
const $overlay = this.appendOverlay();
do {
this.shouldRetryRequest = false;
this.popup = this.createPopup(endpoint);
this.client = new PostMessageRpcClient(this.popup, origin);
try {
this.popup = this.createPopup(endpoint);
this.client = new PostMessageRpcClient(this.popup, origin);
await this.client.init();
return await this.client.call(command, ...(await Promise.all(args)));
}
Expand All @@ -130,12 +130,14 @@ class PopupRequestBehavior extends RequestBehavior {
if (!this.shouldRetryRequest) {
// Remove page overlay
this.removeOverlay($overlay);
this.client.close();
this.popup.close();
if (this.client)
this.client.close();
if (this.popup)
this.popup.close();
}
}
} while (this.shouldRetryRequest);
// the code below should never be executed, unless unexpected things happend
// the code below should never be executed, unless unexpected things happened
if (this.popup)
this.popup.close();
if (this.client)
Expand Down
14 changes: 8 additions & 6 deletions client/dist/HubApi.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
};

var fil = {
"popup-overlay": "Nag-bukas ang isang pop-up.\nMaaring i-click kahit saan para ibalik ito sa harap."
"popup-overlay": "Nag-bukas ang isang pop-up.\nMaaring pindutin kahit saan para ibalik ito sa harap."
};

var fr = {
Expand Down Expand Up @@ -119,9 +119,9 @@
const $overlay = this.appendOverlay();
do {
this.shouldRetryRequest = false;
this.popup = this.createPopup(endpoint);
this.client = new rpc.PostMessageRpcClient(this.popup, origin);
try {
this.popup = this.createPopup(endpoint);
this.client = new rpc.PostMessageRpcClient(this.popup, origin);
await this.client.init();
return await this.client.call(command, ...(await Promise.all(args)));
}
Expand All @@ -133,12 +133,14 @@
if (!this.shouldRetryRequest) {
// Remove page overlay
this.removeOverlay($overlay);
this.client.close();
this.popup.close();
if (this.client)
this.client.close();
if (this.popup)
this.popup.close();
}
}
} while (this.shouldRetryRequest);
// the code below should never be executed, unless unexpected things happend
// the code below should never be executed, unless unexpected things happened
if (this.popup)
this.popup.close();
if (this.client)
Expand Down
44 changes: 35 additions & 9 deletions client/dist/src/PublicRequestTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,23 @@ export interface OnboardRequest extends BasicRequest {
}
export interface ChooseAddressRequest extends BasicRequest {
returnBtcAddress?: boolean;
returnUsdcAddress?: boolean;
minBalance?: number;
disableContracts?: boolean;
disableLegacyAccounts?: boolean;
disableBip39Accounts?: boolean;
disableLedgerAccounts?: boolean;
ui?: number;
}
export interface ChooseAddressResult extends Address {
btcAddress?: string;
usdcAddress?: string;
meta: {
account: {
label: string;
color: string;
};
};
}
export interface SignTransactionRequest extends BasicRequest {
sender: string;
Expand Down Expand Up @@ -141,7 +150,7 @@ export interface MultiCurrencyCheckoutRequest extends BasicRequest {
*/
csrf?: string;
/**
* The data to be included in the transaction. Ignored for `Currenct.BTC` and `Currency.ETH`.
* The data to be included in the transaction. Ignored for `Currency.BTC` and `Currency.ETH`.
* @deprecated use NimiqDirectPaymentOptions.protocolSpecific.extraData instead.
*/
extraData?: Bytes;
Expand Down Expand Up @@ -221,12 +230,12 @@ export interface BitcoinHtlcCreationInstructions {
locktime?: number;
}
export interface PolygonHtlcCreationInstructions extends RelayRequest {
type: 'USDC';
type: 'USDC_MATIC';
/**
* The sender's nonce in the token contract, required when calling the
* contract function `openWithApproval`.
* contract function `openWithPermit`.
*/
approval?: {
permit?: {
tokenNonce: number;
};
}
Expand Down Expand Up @@ -255,7 +264,7 @@ export interface BitcoinHtlcSettlementInstructions {
};
}
export interface PolygonHtlcSettlementInstructions extends RelayRequest {
type: 'USDC';
type: 'USDC_MATIC';
amount: number;
}
export interface EuroHtlcSettlementInstructions {
Expand Down Expand Up @@ -299,7 +308,7 @@ export interface BitcoinHtlcRefundInstructions {
refundAddress: string;
}
export interface PolygonHtlcRefundInstructions extends RelayRequest {
type: 'USDC';
type: 'USDC_MATIC' | 'USDC';
amount: number;
}
export declare type HtlcCreationInstructions = NimiqHtlcCreationInstructions | BitcoinHtlcCreationInstructions | PolygonHtlcCreationInstructions | EuroHtlcCreationInstructions;
Expand Down Expand Up @@ -332,7 +341,7 @@ export interface SetupSwapRequest extends SimpleRequest {
};
polygonAddresses?: Array<{
address: string;
balance: number;
usdcBalance: number;
}>;
kyc?: {
provider: 'TEN31 Pass';
Expand Down Expand Up @@ -500,16 +509,33 @@ export interface SignPolygonTransactionRequest extends BasicRequest, RelayReques
recipientLabel?: string;
/**
* The sender's nonce in the token contract, required when calling the
* contract function `executeWithApproval`.
* contract function `swapWithApproval` for bridged USDC.e.
*/
approval?: {
tokenNonce: number;
};
/**
* The sender's nonce in the token contract, required when calling the
* contract function `transferWithPermit` for native USDC.
*/
permit?: {
tokenNonce: number;
};
/**
* The amount of USDC to transfer. Required when calling the contract
* methods 'redeem' and 'redeemWithSecretInData' for HTLCs.
*/
amount?: number;
/**
* The label of the sending address. Required when calling the contract
* methods 'redeem' and 'redeemWithSecretInData' for HTLCs.
*/
senderLabel?: string;
}
export interface SignedPolygonTransaction {
message: Record<string, any>;
signature: string;
}
export declare type RpcRequest = SignTransactionRequest | SignStakingRequest | CreateCashlinkRequest | ManageCashlinkRequest | CheckoutRequest | BasicRequest | SimpleRequest | ChooseAddressRequest | OnboardRequest | RenameRequest | SignMessageRequest | ExportRequest | SignBtcTransactionRequest | AddBtcAddressesRequest | SignPolygonTransactionRequest | SetupSwapRequest | RefundSwapRequest;
export declare type RpcResult = SignedTransaction | SignedTransaction[] | Account | Account[] | SimpleResult | ChooseAddressResult | Address | Cashlink | Cashlink[] | SignedMessage | ExportResult | SignedBtcTransaction | AddBtcAddressesResult | SignedPolygonTransaction | SetupSwapResult;
export declare type ResultByRequestType<T> = T extends RequestType.RENAME ? Account : T extends RequestType.ONBOARD | RequestType.SIGNUP | RequestType.LOGIN | RequestType.MIGRATE | RequestType.LIST ? Account[] : T extends RequestType.LIST_CASHLINKS ? Cashlink[] : T extends RequestType.CHOOSE_ADDRESS | RequestType.ADD_ADDRESS ? Address : T extends RequestType.SIGN_TRANSACTION ? SignedTransaction : T extends RequestType.SIGN_STAKING ? SignedTransaction[] : T extends RequestType.CHECKOUT ? SignedTransaction | SimpleResult : T extends RequestType.SIGN_MESSAGE ? SignedMessage : T extends RequestType.LOGOUT | RequestType.CHANGE_PASSWORD ? SimpleResult : T extends RequestType.EXPORT ? ExportResult : T extends RequestType.CREATE_CASHLINK | RequestType.MANAGE_CASHLINK ? Cashlink : T extends RequestType.SIGN_BTC_TRANSACTION ? SignedBtcTransaction : T extends RequestType.SIGN_POLYGON_TRANSACTION ? SignedPolygonTransaction : T extends RequestType.ACTIVATE_BITCOIN ? Account : T extends RequestType.ACTIVATE_POLYGON ? Account : T extends RequestType.ADD_BTC_ADDRESSES ? AddBtcAddressesResult : T extends RequestType.SETUP_SWAP ? SetupSwapResult : never;
export declare type ResultByRequestType<T> = T extends RequestType.RENAME ? Account : T extends RequestType.ONBOARD | RequestType.SIGNUP | RequestType.LOGIN | RequestType.MIGRATE | RequestType.LIST ? Account[] : T extends RequestType.LIST_CASHLINKS ? Cashlink[] : T extends RequestType.CHOOSE_ADDRESS ? ChooseAddressResult : T extends RequestType.ADD_ADDRESS ? Address : T extends RequestType.SIGN_TRANSACTION ? SignedTransaction : T extends RequestType.SIGN_STAKING ? SignedTransaction[] : T extends RequestType.CHECKOUT ? SignedTransaction | SimpleResult : T extends RequestType.SIGN_MESSAGE ? SignedMessage : T extends RequestType.LOGOUT | RequestType.CHANGE_PASSWORD ? SimpleResult : T extends RequestType.EXPORT ? ExportResult : T extends RequestType.CREATE_CASHLINK | RequestType.MANAGE_CASHLINK ? Cashlink : T extends RequestType.SIGN_BTC_TRANSACTION ? SignedBtcTransaction : T extends RequestType.SIGN_POLYGON_TRANSACTION ? SignedPolygonTransaction : T extends RequestType.ACTIVATE_BITCOIN ? Account : T extends RequestType.ACTIVATE_POLYGON ? Account : T extends RequestType.ADD_BTC_ADDRESSES ? AddBtcAddressesResult : T extends RequestType.SETUP_SWAP ? SetupSwapResult : never;
2 changes: 1 addition & 1 deletion client/dist/standalone/HubApi.standalone.es.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/dist/standalone/HubApi.standalone.umd.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@nimiq/electrum-client": "https://github.com/nimiq/electrum-client#build",
"@nimiq/fastspot-api": "^1.8.0",
"@nimiq/iqons": "^1.5.2",
"@nimiq/keyguard-client": "https://gitpkg.vercel.app/nimiq/keyguard?scripts.postinstall=cd%20client%20%26%26%20.%2Fbuild-gitpkg.sh&a26831706d45e1859b87835b44a0286392ec9fc1",
"@nimiq/keyguard-client": "https://gitpkg.vercel.app/nimiq/keyguard?scripts.postinstall=cd%20client%20%26%26%20.%2Fbuild-gitpkg.sh&239c43cc712da603ce744eeede76f3b9d56d16b2",
"@nimiq/ledger-api": "^2.3.0",
"@nimiq/network-client": "^0.6.2",
"@nimiq/oasis-api": "^1.1.1",
Expand Down
52 changes: 37 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1499,11 +1499,6 @@
resolved "https://registry.yarnpkg.com/@nimiq/core-web/-/core-web-1.5.3.tgz#f0a4de59394f210f2c2d9cda8ee35c716847d40e"
integrity sha512-W66SS9n3ygYgD52r1GJr1WtYYOkcZsqdtMmDCEwDvkrmeARnHs2sAvj77Wt4PQG8JA7GwK5svIJr6rGccCaekw==

"@nimiq/core-web@1.5.8":
version "1.5.8"
resolved "https://registry.yarnpkg.com/@nimiq/core-web/-/core-web-1.5.8.tgz#da8abef84c6d293cbb9ca495a77f08daa08886b9"
integrity sha512-MNpFbGZetz2eZcHtJVa5tpmLjPf65mTcJBRQkOHS8kWE+f+Z++hdnwWUBQCEAph4oC6bsE5JSuU7VpwcogN7+w==

"@nimiq/core-web@^1.6.0", "@nimiq/core-web@^1.6.1":
version "1.6.1"
resolved "https://registry.yarnpkg.com/@nimiq/core-web/-/core-web-1.6.1.tgz#97cb5b43b257c7f6f6808ef603e9bf686377241f"
Expand Down Expand Up @@ -1554,9 +1549,9 @@
btoa "^1.1.2"
node-lmdb "^0.9.6"

"@nimiq/keyguard-client@https://gitpkg.vercel.app/nimiq/keyguard?scripts.postinstall=cd%20client%20%26%26%20.%2Fbuild-gitpkg.sh&a26831706d45e1859b87835b44a0286392ec9fc1":
"@nimiq/keyguard-client@https://gitpkg.vercel.app/nimiq/keyguard?scripts.postinstall=cd%20client%20%26%26%20.%2Fbuild-gitpkg.sh&239c43cc712da603ce744eeede76f3b9d56d16b2":
version "1.0.0"
resolved "https://gitpkg.vercel.app/nimiq/keyguard?scripts.postinstall=cd%20client%20%26%26%20.%2Fbuild-gitpkg.sh&a26831706d45e1859b87835b44a0286392ec9fc1#b823b6c5547e9128836bc6f1ed2af8ee87a0b9f2"
resolved "https://gitpkg.vercel.app/nimiq/keyguard?scripts.postinstall=cd%20client%20%26%26%20.%2Fbuild-gitpkg.sh&239c43cc712da603ce744eeede76f3b9d56d16b2#8650f137330f7da2bb1a4ecd798b10ace7f9f3a3"

"@nimiq/ledger-api@^2.3.0":
version "2.3.0"
Expand Down Expand Up @@ -1602,11 +1597,6 @@
resolved "https://registry.yarnpkg.com/@nimiq/rpc/-/rpc-0.1.5.tgz#53919b0a3a9abcdfebee0e865f4c663f72a8b8c2"
integrity sha512-oTRThXzpbQOY8jz8h+2KXucWzW40nVfYBWROKXKBrSozhTG0nR+rzCbEm4ZyTC26b4RnmB6y4nYabUXi7gNWcA==

"@nimiq/rpc@^0.3.0":
version "0.3.0"
resolved "https://registry.yarnpkg.com/@nimiq/rpc/-/rpc-0.3.0.tgz#654c05acccc193b7d79fb09b2faf2114945ff872"
integrity sha512-je7fv+wP4nLEgTcZwu3FaGre22qkZ9AYGbStglVaJAxOH+3CvDnnOIa9IjGFaCEhtRQKRaQEvFqa5vN4IVnH+Q==

"@nimiq/rpc@^0.4.1":
version "0.4.1"
resolved "https://registry.yarnpkg.com/@nimiq/rpc/-/rpc-0.4.1.tgz#d5df1e426793afcdd8c407a2968442bbee874dbd"
Expand Down Expand Up @@ -2620,7 +2610,12 @@ ajv-keywords@^3.1.0, ajv-keywords@^3.4.1:
resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.4.1.tgz#ef916e271c64ac12171fd8384eaae6b2345854da"
integrity sha512-RO1ibKvd27e6FEShVFfPALuHI3WjSVNeK5FIsmme/LYRNxjKuNj+Dt7bucLa6NdSv3JcVTyMlm9kGR84z1XpaQ==

ajv@^6.1.0, ajv@^6.10.2, ajv@^6.12.3:
ajv-keywords@^3.5.2:
version "3.5.2"
resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz#31f29da5ab6e00d1c2d329acf7b5929614d5014d"
integrity sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==

ajv@^6.1.0, ajv@^6.10.2, ajv@^6.12.3, ajv@^6.12.5:
version "6.12.6"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4"
integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==
Expand Down Expand Up @@ -4277,6 +4272,23 @@ copy-webpack-plugin@^5.1.1:
serialize-javascript "^2.1.2"
webpack-log "^2.0.0"

copy-webpack-plugin@^6.4.0:
version "6.4.1"
resolved "https://registry.yarnpkg.com/copy-webpack-plugin/-/copy-webpack-plugin-6.4.1.tgz#138cd9b436dbca0a6d071720d5414848992ec47e"
integrity sha512-MXyPCjdPVx5iiWyl40Va3JGh27bKzOTNY3NjUTrosD2q7dR/cLD0013uqJ3BpFbUjyONINjb6qI7nDIJujrMbA==
dependencies:
cacache "^15.0.5"
fast-glob "^3.2.4"
find-cache-dir "^3.3.1"
glob-parent "^5.1.1"
globby "^11.0.1"
loader-utils "^2.0.0"
normalize-path "^3.0.0"
p-limit "^3.0.2"
schema-utils "^3.0.0"
serialize-javascript "^5.0.1"
webpack-sources "^1.4.3"

core-js@^2.4.0, core-js@^2.4.1, core-js@^2.5.3, core-js@^2.6.5:
version "2.6.11"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.11.tgz#38831469f9922bded8ee21c9dc46985e0399308c"
Expand Down Expand Up @@ -7966,6 +7978,11 @@ json5@^1.0.1:
dependencies:
minimist "^1.2.0"

json5@^2.1.2:
version "2.2.3"
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283"
integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==

jsonfile@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb"
Expand Down Expand Up @@ -8437,7 +8454,7 @@ micromatch@^3.1.10, micromatch@^3.1.4:
snapdragon "^0.8.1"
to-regex "^3.0.2"

micromatch@^4.0.0, micromatch@^4.0.2:
micromatch@^4.0.0, micromatch@^4.0.2, micromatch@^4.0.4:
version "4.0.5"
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6"
integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==
Expand Down Expand Up @@ -9574,6 +9591,11 @@ path-type@^3.0.0:
dependencies:
pify "^3.0.0"

path-type@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b"
integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==

pbkdf2@^3.0.17, pbkdf2@^3.0.3:
version "3.1.2"
resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.1.2.tgz#dd822aa0887580e52f1a039dc3eda108efae3075"
Expand Down Expand Up @@ -10616,7 +10638,7 @@ rgba-regex@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/rgba-regex/-/rgba-regex-1.0.0.tgz#43374e2e2ca0968b0ef1523460b7d730ff22eeb3"

rimraf@2, rimraf@^2.5.4, rimraf@^2.6.2, rimraf@^2.6.3, rimraf@^2.7.1:
rimraf@2, rimraf@^2.5.4, rimraf@^2.6.3, rimraf@^2.7.1:
version "2.7.1"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec"
integrity sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==
Expand Down

0 comments on commit f99a7b4

Please sign in to comment.