Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
web-lib
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
郑磊
web-lib
Commits
47f89d7a
Commit
47f89d7a
authored
Mar 19, 2026
by
郑磊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加web3调用方法
parent
baac2e4d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
97 additions
and
1 deletion
+97
-1
native-api.ts
web/native-api.ts
+97
-1
No files found.
web/native-api.ts
View file @
47f89d7a
import
{
callNativeApi
}
from
'./native-api-base'
import
{
callNativeApi
,
callNativeAsyncApi
}
from
'./native-api-base'
/**
* 关闭当前页面
...
...
@@ -29,3 +29,99 @@ export function getBottomSafeHeight(): Promise<number> {
callNativeApi
(
'getBottomSafeHeight'
,
(
value
:
any
)
=>
resolve
(
parseFloat
(
value
))),
)
}
/**
* web3账户
*/
export
interface
Web3Account
{
/**
* 账户索引
*/
index
:
number
/**
* 钱包地址
*/
address
:
string
/**
* 持有代币数据
*/
tokens
:
Web3Token
[]
}
/**
* web3代币信息
*/
export
interface
Web3Token
{
/**
* 代币合约地址
*/
token
:
string
/**
* 代币符号
*/
symbol
:
string
/**
* 代币余额
*/
balance
:
string
}
/**
* 获取钱包数据
*/
export
function
web3GetWallet
(
chain_id
:
number
):
Promise
<
Web3Account
[]
>
{
console
.
log
(
'调用框架方法'
,
'web3GetWallet'
,
chain_id
)
return
new
Promise
<
Web3Account
[]
>
((
resolve
)
=>
callNativeAsyncApi
(
'web3GetWallet'
,
{
chain_id
},
resolve
),
)
}
/**
* 执行web3合约需要的参数
*/
export
interface
Web3ExecContractParams
{
/**
* 链id
*/
chain_id
:
number
/**
* 代币合约地址
*/
token
:
string
/**
* 执行合约需要的代币余额
*/
amount
:
string
/**
* 账户索引(0表示主账户)
*/
index
:
number
/**
* 执行合约时需要传递的data参数
*/
data
:
string
}
/**
* 执行web3合约的结果
*/
export
interface
Web3ExecContractResult
{
/**
* 执行结果,空字符串表示执行成功
*/
result
:
string
/**
* 执行完成的交易hash
*/
hash
:
string
}
/**
* 执行web3合约
*/
export
function
web3ExecContract
(
params
:
Web3ExecContractParams
)
{
console
.
log
(
'调用框架方法'
,
'web3ExecContract'
,
params
)
return
new
Promise
<
Web3ExecContractResult
>
((
resolve
)
=>
callNativeAsyncApi
(
'web3ExecContract'
,
params
,
resolve
),
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment