Skip to content

Commit

Permalink
fix: Types & Ton parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
y3fers0n committed Oct 30, 2024
1 parent da9918e commit ff8bb66
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 30 deletions.
46 changes: 24 additions & 22 deletions android/lib/src/main/res/raw/trust_min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/cosmos/CosmosProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class CosmosProvider extends BaseProvider implements ICosmosProvider {
},
});

return Buffer.from(hash, 'hex');
return new Uint8Array(Buffer.from(hash, 'hex'));
}

async signArbitrary(
Expand Down
4 changes: 2 additions & 2 deletions packages/ios-web3-provider/swift/trust-min.js
Git LFS file not shown
9 changes: 7 additions & 2 deletions packages/solana/SolanaProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ export class SolanaProvider extends BaseProvider implements ISolanaProvider {
});

return {
signature: Buffer.from(SolanaProvider.messageToBuffer(res).buffer),
signature: new Uint8Array(
Buffer.from(SolanaProvider.messageToBuffer(res).buffer),
),
publicKey: this.publicKey?.toBase58(),
};
}
Expand All @@ -209,7 +211,10 @@ export class SolanaProvider extends BaseProvider implements ISolanaProvider {
transaction: T,
signatureEncoded: string,
) {
transaction.addSignature(this.publicKey!, bs58.decode(signatureEncoded));
transaction.addSignature(
this.publicKey!,
bs58.decode(signatureEncoded) as Buffer & Uint8Array,
);
return transaction;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/solana/adapter/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export class TrustWallet implements Wallet {
},
);

outputs.push({ signature: bs58.decode(signature) });
outputs.push({ signature: new Uint8Array(bs58.decode(signature)) });
} else if (inputs.length > 1) {
for (const input of inputs) {
outputs.push(...(await this.#signAndSendTransaction(input)));
Expand Down
15 changes: 14 additions & 1 deletion packages/ton/MobileAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { TonProvider } from './TonProvider';
import { ConnectItemReply, TonAddressItemReply } from './types/TonBridge';

interface ITransaction {
valid_until: number;
Expand Down Expand Up @@ -41,7 +42,19 @@ export class MobileAdapter {
'requestAccounts',
params,
);
return JSON.parse(res);

// Internally we use nonBounceable value, here we remove it from the response
return JSON.parse(res).map((item: ConnectItemReply) => {
if (item.name === 'ton_addr') {
const { nonBounceable, ...rest } = item as TonAddressItemReply & {
nonBounceable: string;
};

return rest;
}

return item;
});
}

case 'tonConnect_reconnect': {
Expand Down
2 changes: 1 addition & 1 deletion packages/ton/types/TonBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type TonProofItem = {

// Untrusted data returned by the wallet.
// If you need a guarantee that the user owns this address and public key, you need to additionally request a ton_proof.
type TonAddressItemReply = {
export type TonAddressItemReply = {
name: 'ton_addr';
address: string; // TON address raw (`0:<hex>`)
network: NETWORK; // network global_id
Expand Down

0 comments on commit ff8bb66

Please sign in to comment.