Skip to content

Commit

Permalink
Fixes for patch and logging
Browse files Browse the repository at this point in the history
  • Loading branch information
jmrossy committed Jan 23, 2024
1 parent 101a4ae commit 0fe0ffd
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ index 8f6305b0263886c5c31fab661c9235723ba1e6e9..a3c7f20135babd6dd7774e4f2ac7e79c
+ if (tag !== 24) {
+ break;
+ }
+ message.accountNumber = longToString(reader.uint64());
+ message.accountNumber = reader.uint64().toString();
+ continue;
+ case 4:
+ if (tag !== 32) {
+ break;
+ }
+ message.sequence = longToString(reader.uint64());
+ message.sequence = reader.uint64().toString();
+ continue;
+ }
+ if ((tag & 7) === 4 || tag === 0) {
Expand Down Expand Up @@ -144,3 +144,37 @@ index 8f6305b0263886c5c31fab661c9235723ba1e6e9..a3c7f20135babd6dd7774e4f2ac7e79c
return account ? (0, stargate_1.accountFromAny)(account) : null;
}
catch (error) {
diff --git a/build/signingcosmwasmclient.js b/build/signingcosmwasmclient.js
index 646bbe7e74343ec2584666ead1ae43fd4f0b3852..b9f86948eae6479d85b58e15205f570dda004afc 100644
--- a/build/signingcosmwasmclient.js
+++ b/build/signingcosmwasmclient.js
@@ -86,6 +86,9 @@ class SigningCosmWasmClient extends cosmwasmclient_1.CosmWasmClient {
throw new Error("Failed to retrieve account from signer");
}
const pubkey = (0, amino_1.encodeSecp256k1Pubkey)(accountFromSigner.pubkey);
+ if (signerAddress.startsWith('inj')) {
+ pubkey['typeUrl'] = '/injective.crypto.v1beta1.ethsecp256k1.PubKey';
+ }
const { sequence } = await this.getSequence(signerAddress);
const { gasInfo } = await this.forceGetQueryClient().tx.simulate(anyMsgs, memo, pubkey, sequence);
(0, utils_1.assertDefined)(gasInfo);
@@ -110,7 +113,8 @@ class SigningCosmWasmClient extends cosmwasmclient_1.CosmWasmClient {
throw new Error(createDeliverTxResponseErrorMessage(result));
}
const parsedLogs = stargate_1.logs.parseRawLog(result.rawLog);
- const codeIdAttr = stargate_1.logs.findAttribute(parsedLogs, "store_code", "code_id");
+ const escapedCodeIdAttr = stargate_1.logs.findAttribute(parsedLogs, "cosmwasm.wasm.v1.EventCodeStored", "code_id");
+ const codeIdAttr = { value: escapedCodeIdAttr.value.replace(/\"/g, "") };
return {
checksum: (0, encoding_1.toHex)((0, crypto_1.sha256)(wasmCode)),
originalSize: wasmCode.length,
@@ -393,6 +397,9 @@ class SigningCosmWasmClient extends cosmwasmclient_1.CosmWasmClient {
throw new Error("Failed to retrieve account from signer");
}
const pubkey = (0, proto_signing_1.encodePubkey)((0, amino_1.encodeSecp256k1Pubkey)(accountFromSigner.pubkey));
+ if (signerAddress.startsWith('inj')) {
+ pubkey['typeUrl'] = '/injective.crypto.v1beta1.ethsecp256k1.PubKey';
+ }
const signMode = signing_1.SignMode.SIGN_MODE_LEGACY_AMINO_JSON;
const msgs = messages.map((msg) => this.aminoTypes.toAmino(msg));
const signDoc = (0, amino_1.makeSignDoc)(msgs, fee, chainId, memo, accountNumber, sequence);
5 changes: 3 additions & 2 deletions src/consts/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,16 @@ export const chains: ChainMap<ChainMetadata & { mailbox?: Address }> = {
displayNameShort: 'Inj. Testnet',
name: 'injectivetestnet',
nativeToken: {
decimals: 6,
decimals: 18,
name: 'Injective',
symbol: 'INJ',
},
bech32Prefix: 'inj',
slip44: 118,
protocol: ProtocolType.Cosmos,
rpcUrls: [{ http: 'https://k8s.testnet.tm.injective.network' }],
rpcUrls: [{ http: 'https://testnet.tm.injective.network' }],
restUrls: [{ http: 'https://testnet.sentry.lcd.injective.network' }],
isTestnet: true,
logoURI: '/logos/injective.svg',
},
};
4 changes: 2 additions & 2 deletions src/consts/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const withdrawalWhitelist = process?.env?.NEXT_PUBLIC_BLOCK_WITHDRAWAL_WHITELIST
const transferBlacklist = process?.env?.NEXT_PUBLIC_TRANSFER_BLACKLIST || '';

interface Config {
debug: boolean; // Enables some debug features in the app
isDevMode: boolean; // Enables some debug features in the app
version: string; // Matches version number in package.json
explorerApiKeys: Record<string, string>; // Optional map of API keys for block explorer
showTipBox: boolean; // Show/Hide the blue tip box above the transfer form
Expand All @@ -21,7 +21,7 @@ interface Config {
}

export const config: Config = Object.freeze({
debug: isDevMode,
isDevMode,
version,
explorerApiKeys,
showTipBox: true,
Expand Down
2 changes: 1 addition & 1 deletion src/consts/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const tokenList: WarpTokenConfig = [
chainId: 'injective-888',
name: 'Injective Coin',
symbol: 'INJ',
decimals: 6,
decimals: 18,
hypNativeAddress: 'inj1wn32e0e07yytd4m03n8mynnp6qzgg75qmhsq88',
logoURI: '/logos/injective.svg',
},
Expand Down
14 changes: 9 additions & 5 deletions src/utils/logger.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
/* eslint-disable no-console */
import { captureException } from '@sentry/nextjs';

import { config } from '../consts/config';

export const logger = {
debug: (...args: any[]) => console.debug(...args),
info: (...args: any[]) => console.info(...args),
warn: (...args: any[]) => console.warn(...args),
error: (message: string, err: any, ...args: any[]) => {
console.error(...args);
const filteredArgs = args.filter(isSafeSentryArg);
const extra = filteredArgs.reduce((acc, arg, i) => ({ ...acc, [`arg${i}`]: arg }), {});
extra['message'] = message;
captureException(err, { extra });
console.error(message, err, ...args);
if (!config.isDevMode) {
const filteredArgs = args.filter(isSafeSentryArg);
const extra = filteredArgs.reduce((acc, arg, i) => ({ ...acc, [`arg${i}`]: arg }), {});
extra['message'] = message;
captureException(err, { extra });
}
},
};

Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1860,7 +1860,7 @@ __metadata:

"@cosmjs/cosmwasm-stargate@patch:@cosmjs/cosmwasm-stargate@npm%3A0.31.3#~/.yarn/patches/@cosmjs-cosmwasm-stargate-npm-0.31.3-4b3bafffd4.patch":
version: 0.31.3
resolution: "@cosmjs/cosmwasm-stargate@patch:@cosmjs/cosmwasm-stargate@npm%3A0.31.3#~/.yarn/patches/@cosmjs-cosmwasm-stargate-npm-0.31.3-4b3bafffd4.patch::version=0.31.3&hash=1e2f10"
resolution: "@cosmjs/cosmwasm-stargate@patch:@cosmjs/cosmwasm-stargate@npm%3A0.31.3#~/.yarn/patches/@cosmjs-cosmwasm-stargate-npm-0.31.3-4b3bafffd4.patch::version=0.31.3&hash=1f2ffa"
dependencies:
"@cosmjs/amino": "npm:^0.31.3"
"@cosmjs/crypto": "npm:^0.31.3"
Expand All @@ -1873,7 +1873,7 @@ __metadata:
cosmjs-types: "npm:^0.8.0"
long: "npm:^4.0.0"
pako: "npm:^2.0.2"
checksum: 9d5393554d40b5658a19768539660ddb96549de339274caee1cfad1784e5fa1f78cdb55ce161d755121e60493f172c8aa275ba448d865453b4771e04f8e8e079
checksum: e5797e52ba6104c51280edd1587948b3c089b5746f82816c7d778f1d728e2507b6d0242cd87e5839c5af2e1b5e04fb1b7187caf28bbc1fbe872cbbbef68cc0ad
languageName: node
linkType: hard

Expand Down

0 comments on commit 0fe0ffd

Please sign in to comment.