Skip to content

Commit

Permalink
Release Adena Wallet 'v1.8.2' (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
jinoosss authored Nov 9, 2023
2 parents aa5ba5d + 2a09980 commit 003c0a8
Show file tree
Hide file tree
Showing 11 changed files with 679 additions and 95 deletions.
541 changes: 541 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: '@yarnpkg/plugin-workspace-tools'
spec: "@yarnpkg/plugin-workspace-tools"
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"

pnpMode: loose

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "adena-wallet",
"version": "1.8.1",
"version": "1.8.2",
"description": "Adena Wallet",
"license": "Adena License",
"private": true,
Expand Down
5 changes: 3 additions & 2 deletions packages/adena-extension/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "adena-extension",
"version": "1.8.1",
"version": "1.8.2",
"private": true,
"description": "Adena is a friendly browser extension wallet for the Gnoland blockchain.",
"scripts": {
Expand Down Expand Up @@ -74,7 +74,8 @@
"webpack-merge": "^5.8.0"
},
"dependencies": {
"@gnolang/gno-js-client": "1.0.1",
"@gnolang/gno-js-client": "^1.1.6",
"@gnolang/tm2-js-client": "^1.1.4",
"@tanstack/react-query": "^4.10.3",
"@vespaiach/axios-fetch-adapter": "^0.3.0",
"adena-module": "*",
Expand Down
2 changes: 1 addition & 1 deletion packages/adena-extension/public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Adena",
"description": "Adena is a friendly browser extension wallet for the Gnoland blockchain.",
"manifest_version": 3,
"version": "1.8.1",
"version": "1.8.2",
"action": {
"default_popup": "popup.html"
},
Expand Down
19 changes: 10 additions & 9 deletions packages/adena-extension/src/common/provider/gno/gno-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
RPCResponse,
parseABCI,
RestService,
BroadcastTxResult,
BroadcastTxCommitResult,
BroadcastTxSyncResult,
TransactionEndpoint,
} from '@gnolang/tm2-js-client';
import fetchAdapter from '@vespaiach/axios-fetch-adapter';
Expand Down Expand Up @@ -131,14 +132,14 @@ export class GnoProvider extends GnoJSONRPCProvider {
.catch(() => null);
}

public async sendTransaction(tx: string): Promise<string> {
const response: BroadcastTxResult = await RestService.post<BroadcastTxResult>(this.baseURL, {
request: newRequest(TransactionEndpoint.BROADCAST_TX_SYNC, [tx]),
});
if (response.error) {
throw Tm2Error.createTm2Error(response.hash, response.error['@type']);
}
return response.hash;
public async sendTransactionSync(tx: string): Promise<BroadcastTxSyncResult> {
const response = this.sendTransaction(tx, TransactionEndpoint.BROADCAST_TX_SYNC);
return response;
}

public async sendTransactionCommit(tx: string): Promise<BroadcastTxCommitResult> {
const response = this.sendTransaction(tx, TransactionEndpoint.BROADCAST_TX_COMMIT);
return response;
}

public waitResultForTransaction(hash: string, timeout?: number) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { RoutePath } from '@router/path';
import { validateInjectionData } from '@inject/message/methods';
import BigNumber from 'bignumber.js';
import { useNetwork } from '@hooks/use-network';
import { Tm2Error } from '@common/errors/common/tm2-error';
import { TM2Error } from "@gnolang/tm2-js-client"

function mappedTransactionData(document: StdSignDoc) {
return {
Expand Down Expand Up @@ -184,33 +184,37 @@ const ApproveTransactionContainer: React.FC = () => {
document
);
const transaction = await transactionService.createTransaction(document, signature);
const hash = await new Promise<string>((resolve, reject) => {
const hash = transactionService.createHash(transaction);
const responseHash = await new Promise<string>((resolve) => {
transactionService.sendTransaction(transaction)
.then(resolve)
.catch(reject);
.catch((error: TM2Error) => {
const message = {
hash,
error: {
name: error.name,
message: error.message,
log: error.log,
},
};
chrome.runtime.sendMessage(
InjectionMessageInstance.failure('TRANSACTION_FAILED', message, requestData?.key),
)
});

checkHealth(currentNetwork.rpcUrl, requestData?.key);
})
if (hash.length > 0) {
if (hash === responseHash) {
chrome.runtime.sendMessage(
InjectionMessageInstance.success('TRANSACTION_SUCCESS', { hash }, requestData?.key),
);
return true;
} else {
chrome.runtime.sendMessage(
InjectionMessageInstance.failure('TRANSACTION_FAILED', {}, requestData?.key),
InjectionMessageInstance.failure('TRANSACTION_FAILED', { hash }, requestData?.key),
);
}
} catch (e) {
if (e instanceof Tm2Error) {
chrome.runtime.sendMessage(
InjectionMessageInstance.failure(
'TRANSACTION_FAILED',
e.response,
requestData?.key,
),
);
}
if (e instanceof Error) {
const message = e.message;
if (message.includes('Ledger')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { InjectionMessage, InjectionMessageInstance } from '@inject/message';
import { useCurrentAccount } from '@hooks/use-current-account';
import { useAdenaContext } from '@hooks/use-context';
import { useNetwork } from '@hooks/use-network';
import { TM2Error } from "@gnolang/tm2-js-client"

interface ApproveSignLedgerLoadingState {
requestData?: InjectionMessage;
Expand Down Expand Up @@ -45,8 +46,23 @@ const ApproveTransactionLedgerLoadingContainer: React.FC = () => {

const result = await transactionService.createSignatureWithLedger(currentAccount, document).then(async (signature) => {
const transaction = await transactionService.createTransaction(document, signature);
const hash = await transactionService.sendTransaction(transaction);
if (hash.length > 0) {
const hash = transactionService.createHash(transaction);
const responseHash = await transactionService.sendTransaction(transaction)
.catch((error: TM2Error) => {
const message = {
hash,
error: {
name: error.name,
message: error.message,
log: error.log,
},
};
chrome.runtime.sendMessage(
InjectionMessageInstance.failure('TRANSACTION_FAILED', message, requestData?.key),
)
});

if (hash === responseHash) {
chrome.runtime.sendMessage(
InjectionMessageInstance.success('TRANSACTION_SUCCESS', { hash }, requestData?.key),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ export class TransactionService {
*/
public sendTransaction = async (transaction: Array<number>) => {
const provider = this.getGnoProvider();
const hash = await provider.sendTransaction(Buffer.from(transaction).toString('base64'));
provider.waitResultForTransaction(hash).then(console.log);
return hash;
const encodedTransaction = Buffer.from(transaction).toString('base64');
const response = await provider.sendTransactionCommit(encodedTransaction);
return response.hash;
};

public createHash(transaction: Array<number>) {
Expand Down
2 changes: 1 addition & 1 deletion packages/adena-module/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "adena-module",
"private": true,
"version": "1.8.1",
"version": "1.8.2",
"description": "Adena's Wallet",
"main": "./dist/index.umd.js",
"module": "./dist/index.esm.js",
Expand Down
Loading

0 comments on commit 003c0a8

Please sign in to comment.