From 6d8d8932a249c1e9619965fdec387fd3317743f7 Mon Sep 17 00:00:00 2001 From: Michael Wallace Date: Fri, 20 Oct 2023 16:19:25 +1100 Subject: [PATCH] fix: Various fixes for attestation --- package-lock.json | 18 +++++------ package.json | 2 +- src/client/auth/ticketZKProof.ts | 9 +++++- src/client/index.ts | 2 +- src/client/views/select-issuers.ts | 51 +++++++++++++++--------------- src/outlet/ticketStorage.ts | 9 ++++-- 6 files changed, 51 insertions(+), 40 deletions(-) diff --git a/package-lock.json b/package-lock.json index a48c93f7..9313037f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,18 +1,18 @@ { "name": "@tokenscript/token-negotiator", - "version": "3.1.1", + "version": "3.2.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@tokenscript/token-negotiator", - "version": "3.1.1", + "version": "3.2.0", "license": "MIT", "dependencies": { "@onflow/fcl": "^1.3.2", "@onflow/types": "^1.0.5", "@peculiar/asn1-schema": "^2.2.0", - "@tokenscript/attestation": "0.7.0-rc.1", + "@tokenscript/attestation": "0.7.0-rc.2", "@toruslabs/torus-embed": "^2.2.5", "@walletconnect/qrcode-modal": "^1.8.0", "@walletconnect/types": "^2.1.5", @@ -4677,9 +4677,9 @@ } }, "node_modules/@tokenscript/attestation": { - "version": "0.7.0-rc.1", - "resolved": "https://registry.npmjs.org/@tokenscript/attestation/-/attestation-0.7.0-rc.1.tgz", - "integrity": "sha512-FDA41LBbhYphXBDXl/kec4N7MLtBo91LLrwuF0I0PSnoC4Y4ZukbHl4lpVgSjGnu4vrs6QIjXRG2APsaScIYLw==", + "version": "0.7.0-rc.2", + "resolved": "https://registry.npmjs.org/@tokenscript/attestation/-/attestation-0.7.0-rc.2.tgz", + "integrity": "sha512-5C9KLU0cyT9gkvb6RYXZIlp/VWCZKq+Isev/aPtwcU/sR3N9ZYobJRQsayTUnxYERRq8YOmADxZjr7K2mCnEjQ==", "hasInstallScript": true, "dependencies": { "@ethereum-attestation-service/eas-sdk": "^0.29.1", @@ -23348,9 +23348,9 @@ } }, "@tokenscript/attestation": { - "version": "0.7.0-rc.1", - "resolved": "https://registry.npmjs.org/@tokenscript/attestation/-/attestation-0.7.0-rc.1.tgz", - "integrity": "sha512-FDA41LBbhYphXBDXl/kec4N7MLtBo91LLrwuF0I0PSnoC4Y4ZukbHl4lpVgSjGnu4vrs6QIjXRG2APsaScIYLw==", + "version": "0.7.0-rc.2", + "resolved": "https://registry.npmjs.org/@tokenscript/attestation/-/attestation-0.7.0-rc.2.tgz", + "integrity": "sha512-5C9KLU0cyT9gkvb6RYXZIlp/VWCZKq+Isev/aPtwcU/sR3N9ZYobJRQsayTUnxYERRq8YOmADxZjr7K2mCnEjQ==", "requires": { "@ethereum-attestation-service/eas-sdk": "^0.29.1", "@peculiar/asn1-schema": "^2.3.3", diff --git a/package.json b/package.json index bf42c77e..71828dd9 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "@onflow/fcl": "^1.3.2", "@onflow/types": "^1.0.5", "@peculiar/asn1-schema": "^2.2.0", - "@tokenscript/attestation": "0.7.0-rc.1", + "@tokenscript/attestation": "0.7.0-rc.2", "@toruslabs/torus-embed": "^2.2.5", "@walletconnect/qrcode-modal": "^1.8.0", "@walletconnect/types": "^2.1.5", diff --git a/src/client/auth/ticketZKProof.ts b/src/client/auth/ticketZKProof.ts index b9365213..7fadedb3 100644 --- a/src/client/auth/ticketZKProof.ts +++ b/src/client/auth/ticketZKProof.ts @@ -123,7 +123,14 @@ export class TicketZKProof extends AbstractAuthentication implements Authenticat if (type === 'eas') { const schema = issuerConfig.eas ? { fields: issuerConfig.eas.fields } : DEFAULT_EAS_SCHEMA const easZkProof = new EasZkProof(schema, { ...DEFAULT_RPC_MAP, ...ethRPCMap }) - await easZkProof.validateUseTicket(proof, issuerConfig.base64attestorPubKey, issuerConfig.base64senderPublicKeys, ethAddress) + await easZkProof.validateUseTicket( + proof, + issuerConfig.base64attestorPubKey, + issuerConfig.base64senderPublicKeys, + ethAddress, + 'asn', + 'asn', + ) } else { Authenticator.validateUseTicket(proof, issuerConfig.base64attestorPubKey, issuerConfig.base64senderPublicKeys, ethAddress) } diff --git a/src/client/index.ts b/src/client/index.ts index b095e948..7afb56e3 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -579,7 +579,7 @@ export class Client { } } } catch (error) { - errorHandler('popup error', 'error', () => this.eventSender('error', { issuer, error }), null, true, false) + errorHandler(error, 'error', () => this.eventSender('error', { issuer, error }), null, true, false) continue } diff --git a/src/client/views/select-issuers.ts b/src/client/views/select-issuers.ts index f91bd5cc..f7772e49 100644 --- a/src/client/views/select-issuers.ts +++ b/src/client/views/select-issuers.ts @@ -158,10 +158,10 @@ export class SelectIssuers extends AbstractView { new IconView(elem, params).render() } - this.issuerListContainer.addEventListener('click', (e: any) => { + this.issuerListContainer.addEventListener('click', async (e: any) => { if (e.target.classList.contains('connect-btn-tn')) { - this.connectTokenIssuer(e) - this.client.getTokenStore().setIncrementCollectionLoadAttempts(e.target.dataset.issuer); + await this.connectTokenIssuer(e) + this.client.getTokenStore().setIncrementCollectionLoadAttempts(e.target.dataset.issuer) } else if (e.target.classList.contains('tokens-btn-tn')) { const issuer = e.target.parentNode.dataset.issuer this.navigateToTokensView(issuer) @@ -171,11 +171,14 @@ export class SelectIssuers extends AbstractView { issuerConnectMarkup(title: string, image: string | undefined, issuer: string, tokens: any[], data: Issuer) { let buttonText = '' - const collectLoadAttempts = this.client.getTokenStore().getCollectionLoadAttempts(issuer); - let issuerButtonText = this.params.options?.loadAction ?? "Load Collection"; - if (collectLoadAttempts >= 1) issuerButtonText = this.params.options?.repeatAction ?? 'Retry'; + const collectLoadAttempts = this.client.getTokenStore().getCollectionLoadAttempts(issuer) + let issuerButtonText = this.params.options?.loadAction ?? 'Load Collection' + if (collectLoadAttempts >= 1) issuerButtonText = this.params.options?.repeatAction ?? 'Retry' // @ts-ignore - if (tokens?.length) buttonText = data?.fungible ? this.params.options?.balanceFoundEvent ?? 'Balance found' : `${tokens.length} ${this.params.options?.nftsFoundEvent ?? 'Token(s) Available'}` + if (tokens?.length) + buttonText = data?.fungible + ? this.params.options?.balanceFoundEvent ?? 'Balance found' + : `${tokens.length} ${this.params.options?.nftsFoundEvent ?? 'Token(s) Available'}` return `