Skip to content

Commit 3086298

Browse files
authored
fix(bsc): align walletapi pipeline and release v1.0.6
* fix(bsc): align walletapi transaction pipeline and token transfer path * release: v1.0.6
1 parent 656686c commit 3086298

7 files changed

Lines changed: 624 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# 更新日志
22

3+
## [1.0.6] - 2026-02-18
4+
5+
修复 BSC 转账广播链路并透传 tokenAddress
6+
7+
<!-- last-commit: b6845de129e00e7720e0f12402c89008b995b93f -->
8+
39
## [1.0.5] - 2026-02-18
410

511
修复 miniapp Crypto 授权手势校验与错误提示
@@ -257,4 +263,3 @@ DWEB 安装资源与发布流程优化
257263
DWEB 安装资源与版本发布流程优化
258264

259265
<!-- last-commit: 5c166987badd06a0a81f4fd5a48ef6763d586be0 -->
260-

manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
"author": [
1919
"@bfmeta.info"
2020
],
21-
"version": "1.0.5",
22-
"change_log": "修复 miniapp Crypto 授权手势校验与错误提示",
21+
"version": "1.0.6",
22+
"change_log": "修复 BSC 转账广播链路并透传 tokenAddress",
2323
"categories": [
2424
"application",
2525
"wallet"

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@biochain/keyapp",
33
"private": true,
4-
"version": "1.0.5",
4+
"version": "1.0.6",
55
"type": "module",
66
"packageManager": "pnpm@10.28.0",
77
"scripts": {
@@ -218,5 +218,5 @@
218218
"packages/*",
219219
"miniapps/*"
220220
],
221-
"lastChangelogCommit": "873c9bdfd2492f1222f46a649a07055ca64bf6a5"
221+
"lastChangelogCommit": "b6845de129e00e7720e0f12402c89008b995b93f"
222222
}

src/hooks/use-send.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ export function useSend(options: UseSendOptions = {}): UseSendReturn {
153153
fromAddress,
154154
toAddress,
155155
amount: state.amount ?? undefined,
156+
tokenAddress: state.asset?.contractAddress,
156157
})
157158
: await fetchBioforestFee(chainConfig!, fromAddress!);
158159

@@ -327,6 +328,7 @@ export function useSend(options: UseSendOptions = {}): UseSendReturn {
327328
fromAddress,
328329
toAddress: state.toAddress,
329330
amount: state.amount,
331+
tokenAddress: state.asset.contractAddress,
330332
});
331333

332334
if (result.status === 'password') {

src/hooks/use-send.web3.test.ts

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,16 @@ vi.mock('@/services/chain-adapter/providers', async () => {
3030
};
3131
});
3232

33-
import { submitWeb3Transfer } from './use-send.web3';
33+
import { fetchWeb3Fee, submitWeb3Transfer } from './use-send.web3';
3434

3535
type MockChainProvider = {
3636
supportsFullTransaction: boolean;
37+
supportsBuildTransaction?: boolean;
38+
supportsFeeEstimate?: boolean;
3739
buildTransaction: (intent: unknown) => Promise<unknown>;
3840
signTransaction: (unsignedTx: unknown, options: { privateKey: Uint8Array }) => Promise<unknown>;
3941
broadcastTransaction: (signedTx: unknown) => Promise<string>;
42+
estimateFee?: (unsignedTx: unknown) => Promise<{ standard: { amount: Amount } }>;
4043
};
4144

4245
function createChainConfig(): ChainConfig {
@@ -151,4 +154,60 @@ describe('submitWeb3Transfer', () => {
151154

152155
expect(result).toEqual({ status: 'ok', txHash: 'tx-hash' });
153156
});
157+
158+
it('passes tokenAddress to buildTransaction', async () => {
159+
const provider = createMockProvider();
160+
mockGetChainProvider.mockReturnValue(provider);
161+
162+
await submitWeb3Transfer({
163+
chainConfig: createChainConfig(),
164+
walletId: 'wallet-1',
165+
password: 'pwd',
166+
fromAddress: 'TFromAddress',
167+
toAddress: 'TToAddress',
168+
amount: Amount.fromRaw('1000000', 6, 'USDT'),
169+
tokenAddress: 'TTokenContract',
170+
});
171+
172+
expect(provider.buildTransaction).toHaveBeenCalledWith(
173+
expect.objectContaining({
174+
tokenAddress: 'TTokenContract',
175+
}),
176+
);
177+
});
178+
});
179+
180+
describe('fetchWeb3Fee', () => {
181+
beforeEach(() => {
182+
vi.clearAllMocks();
183+
});
184+
185+
it('passes tokenAddress to buildTransaction', async () => {
186+
const provider: MockChainProvider = createMockProvider({
187+
supportsFullTransaction: true,
188+
supportsFeeEstimate: true,
189+
supportsBuildTransaction: true,
190+
buildTransaction: vi.fn(async () => ({ data: { txID: 'mock-tx' } })),
191+
estimateFee: vi.fn(async () => ({
192+
standard: { amount: Amount.fromRaw('1000', 6, 'TRX') },
193+
})),
194+
});
195+
196+
mockGetChainProvider.mockReturnValue(provider);
197+
198+
const result = await fetchWeb3Fee({
199+
chainConfig: createChainConfig(),
200+
fromAddress: 'TFromAddress',
201+
toAddress: 'TToAddress',
202+
amount: Amount.fromRaw('1000000', 6, 'USDT'),
203+
tokenAddress: 'TTokenContract',
204+
});
205+
206+
expect(provider.buildTransaction).toHaveBeenCalledWith(
207+
expect.objectContaining({
208+
tokenAddress: 'TTokenContract',
209+
}),
210+
);
211+
expect(result.amount.toRawString()).toBe('1000');
212+
});
154213
});

src/hooks/use-send.web3.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,16 @@ export interface FetchWeb3FeeParams {
131131
fromAddress: string;
132132
toAddress: string;
133133
amount?: Amount | undefined;
134+
tokenAddress?: string | undefined;
134135
}
135136

136-
export async function fetchWeb3Fee({ chainConfig, fromAddress, toAddress, amount }: FetchWeb3FeeParams): Promise<Web3FeeResult> {
137+
export async function fetchWeb3Fee({
138+
chainConfig,
139+
fromAddress,
140+
toAddress,
141+
amount,
142+
tokenAddress,
143+
}: FetchWeb3FeeParams): Promise<Web3FeeResult> {
137144
const chainProvider = getChainProvider(chainConfig.id);
138145

139146
if (!chainProvider.supportsFeeEstimate || !chainProvider.supportsBuildTransaction) {
@@ -151,6 +158,7 @@ export async function fetchWeb3Fee({ chainConfig, fromAddress, toAddress, amount
151158
from: fromAddress,
152159
to: toAddress,
153160
amount: estimateAmount,
161+
tokenAddress,
154162
});
155163

156164
const feeEstimate = await chainProvider.estimateFee!(unsignedTx);
@@ -185,6 +193,7 @@ export interface SubmitWeb3Params {
185193
fromAddress: string;
186194
toAddress: string;
187195
amount: Amount;
196+
tokenAddress?: string | undefined;
188197
}
189198

190199
export async function submitWeb3Transfer({
@@ -194,6 +203,7 @@ export async function submitWeb3Transfer({
194203
fromAddress,
195204
toAddress,
196205
amount,
206+
tokenAddress,
197207
}: SubmitWeb3Params): Promise<SubmitWeb3Result> {
198208
// Get mnemonic from wallet storage
199209
let secret: string;
@@ -228,6 +238,7 @@ export async function submitWeb3Transfer({
228238
from: fromAddress,
229239
to: toAddress,
230240
amount,
241+
tokenAddress,
231242
});
232243

233244
// Sign transaction

0 commit comments

Comments
 (0)