diff --git a/package.json b/package.json
index a3141e4f..5a284d8f 100644
--- a/package.json
+++ b/package.json
@@ -41,6 +41,7 @@
"echarts": "4.8.0",
"leaflet": "1.6.0",
"ledger-cosmos-js": "2.1.8",
+ "long": "^5.2.0",
"node-fetch": "^2.6.1",
"pako": "^1.0.11",
"portal-vue": "2.1.7",
diff --git a/src/libs/data/aminotypes.js b/src/libs/data/aminotypes.js
index a26c10e3..e1c04046 100644
--- a/src/libs/data/aminotypes.js
+++ b/src/libs/data/aminotypes.js
@@ -338,7 +338,6 @@ function createDefaultTypes(prefix) {
"/ibc.applications.transfer.v1.MsgTransfer": {
aminoType: "cosmos-sdk/MsgTransfer",
toAmino: ({ sourcePort, sourceChannel, token, sender, receiver, timeoutHeight, timeoutTimestamp, }) => {
- console.log('toAmino', sourceChannel, sourcePort)
var _a, _b, _c;
return ({
source_port: sourcePort,
@@ -370,6 +369,31 @@ function createDefaultTypes(prefix) {
timeoutTimestamp: long_1.default.fromString(timeout_timestamp || "0", true),
}),
},
+ // osmosis
+ "/osmosis.gamm.v1beta1.MsgSwapExactAmountIn": {
+ aminoType: "cosmos-sdk/MsgSwapExactAmountIn",
+ toAmino: ({ sender, routes, tokenIn, tokenOutMinAmount}) => {
+ utils_1.assertDefinedAndNotNull(tokenIn.amount, "missing amount");
+ return {
+ sender,
+ routes: routes.map(({poolId, tokenOutDenom}) => ({pool_id: poolId, token_out_denom: tokenOutDenom})),
+ token_in: {
+ amount: tokenIn.amount,
+ denom: tokenIn.denom,
+ },
+ token_out_min_amount: tokenOutMinAmount,
+ };
+ },
+ fromAmino: ({ sender, routes, token_in, token_out_min_amount }) => ({
+ sender,
+ routes: routes.map(({pool_id, token_out_denom})=>({poolId: long_1.default.fromString(pool_id), tokenOutDenom: token_out_denom})),
+ tokenIn: {
+ amount: long_1.default.fromString(token_in.amount),
+ denom: token_in.denom,
+ },
+ tokenOutMinAmount: long_1.default.fromString(token_out_min_amount),
+ }),
+ },
};
}
/**
@@ -385,6 +409,7 @@ class AminoTypes {
this.register = Object.assign(Object.assign({}, filteredDefaultTypes), additions);
}
toAmino({ typeUrl, value }) {
+ console.log('typeurl:', typeUrl, value)
const converter = this.register[typeUrl];
if (!converter) {
throw new Error("Type URL does not exist in the Amino message type register. " +
diff --git a/src/libs/data/data.js b/src/libs/data/data.js
index c4e4d2f7..8634b9ce 100644
--- a/src/libs/data/data.js
+++ b/src/libs/data/data.js
@@ -171,7 +171,7 @@ export async function sign(device, chainId, signerAddress, messages, fee, memo,
// Ensure the address has some tokens to spend
const client = await PingWalletClient.offline(signer)
// const client = await SigningStargateClient.offline(signer)
- return client.signAmino(device === 'keplr' ? signerAddress : toSignAddress(signerAddress), messages, fee, memo, signerData)
+ return client.signAmino2(device === 'keplr' ? signerAddress : toSignAddress(signerAddress), messages, fee, memo, signerData)
// return signDirect(signer, signerAddress, messages, fee, memo, signerData)
}
diff --git a/src/libs/data/signing.js b/src/libs/data/signing.js
index ac4743c1..5cf26373 100644
--- a/src/libs/data/signing.js
+++ b/src/libs/data/signing.js
@@ -2,7 +2,8 @@
import { SigningStargateClient } from '@cosmjs/stargate'
// import { MsgTransfer } from './msg-transfer'
-// import { AminoTypes } from './aminotypes'
+import { AminoTypes } from './aminotypes'
+import { MsgSwapExactAmountIn } from '../msg'
const amino_1 = require('@cosmjs/amino')
const encoding_1 = require('@cosmjs/encoding')
@@ -15,12 +16,12 @@ export default class PingWalletClient extends SigningStargateClient {
static async offline(signer, options = {}) {
const instance = new PingWalletClient(undefined, signer, options)
- // instance.registry.register('/ibc.applications.transfer.v1.MsgTransfer', MsgTransfer)
+ instance.registry.register('/osmosis.gamm.v1beta1.MsgSwapExactAmountIn', MsgSwapExactAmountIn)
// console.log('registory:', instance.registry, AminoTypes)
- // const { aminoTypes = new AminoTypes({ prefix: options.prefix }) } = options
- // instance.aminoTypes = aminoTypes
- // console.log('aminoType:', instance.aminoTypes)
+ const { aminoTypes = new AminoTypes({ prefix: options.prefix }) } = options
+ instance.aminoTypes = aminoTypes
+ console.log('aminoType:', instance.aminoTypes)
return instance
}
@@ -32,13 +33,16 @@ export default class PingWalletClient extends SigningStargateClient {
}
const pubkey = proto_signing_1.encodePubkey(amino_1.encodeSecp256k1Pubkey(accountFromSigner.pubkey))
const signMode = signing_1.SignMode.SIGN_MODE_LEGACY_AMINO_JSON
+ console.log('messages:', messages)
const msgs = messages.map(msg => this.aminoTypes.toAmino(msg))
+ console.log('msgs:', msgs)
const signDoc = amino_1.makeSignDoc(msgs, fee, chainId, memo, accountNumber, sequence)
const { signature, signed } = await this.signer.signAmino(signerAddress, signDoc)
const signedTxBody = {
messages: signed.msgs.map(msg => this.aminoTypes.fromAmino(msg)),
memo: signed.memo,
}
+ console.log(signedTxBody)
const signedTxBodyEncodeObject = {
typeUrl: '/cosmos.tx.v1beta1.TxBody',
value: signedTxBody,
diff --git a/src/views/components/KlineTrade/PlaceForm.vue b/src/views/components/KlineTrade/PlaceForm.vue
index 981b3c42..0df6d46a 100644
--- a/src/views/components/KlineTrade/PlaceForm.vue
+++ b/src/views/components/KlineTrade/PlaceForm.vue
@@ -8,6 +8,7 @@
Balance