bdcontract-sdk-javascript/test/http.html

111 lines
5.1 KiB
HTML
Raw Normal View History

2023-03-14 17:15:57 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<!-- <script src="../node_modules/cross-fetch/dist/cross-fetch.js"></script> -->
<script src="../lib/index.js"></script>
<script src="./sm2.js"></script>
<script src="./cryptico.iife.js"></script>
<!-- <script src="../dist/bdcontract-sdk.iife.js"></script> -->
<script>
function print(string) {
document.write(`${string}\n\n`)
}
;(async () => {
// const url = 'http://021.node.internetapi.cn:18010/SCIDE'
// const url = 'http://022.node.internetapi.cn:18010/SCIDE'
const url = 'http://041.node.internetapi.cn:21030/SCIDE/SCIDE'
// const url = 'http://localhost/8080/api/sse'
const sm2Key = {
privateKey:
'd675782acf011dbc01a73c7967ccff9564486f7c3a9f5d5de151caffaa18936',
publicKey:
'04303718771b9323c204e607639f14469f9a94e55b0964a408ad3b3864b0493b645d7070da0d550f0c54b934275a8e88dedc3024467b0566db5c1108b1baeaae27',
// '04303718771b9323c204e607639f14469f9a94e55b0964a408ad3b3864b0493b645d7070da0d550f0c54b934275a8e88dedc3024467b0566db5c1108b1baeaae27',
}
// eslint-disable-next-line no-undef
const client = new bdcontract.HttpClient(url, sm2Key)
const data = await client.executeContract(
'ControlProxy',
'getDoList',
1,
true,
)
// await client.applyNodeRole('ContractProvider')
// await client.applyNodeRole('ContractInstanceManager')
// const data = await client.authNodeRole(
// true,
// '0430276215ff414e0047a532d4dea32048ad4ec60a729ce8e4248c98889d244c3b27b9549e5cb664ce324e2acac4a81590321f4196ca159cb577e06a3eb553ce6a',
// )
// await client.authNodeRole(true,'0430276215ff414e0047a532d4dea32048ad4ec60a729ce8e4248c98889d244c3b27b9549e5cb664ce324e2acac4a81590321f4196ca159cb577e06a3eb553ce6a')
// const dataa = [
// {
// nodeName: '18000',
// pubKey:
// '041016acfbc8f4068a24d38a99a1355449ba958f7e905d66617cec9eda311e3001f8d15a4440b6eb61d7b7bd94bb434b30a518623c1593540e7d32eb72fe8088e1',
// },
// ]
// await client.createTrustUnit(dataa, '12345')
// const data = client.startContractByYPK({
// // signature:
// // '3045022100e13a8a1493ebbbb31e0b4d387ea061fd73a362b1e9fa0000066e87c5e9612907022037e04cb5ffa31fca23260a144eff2cbc8c04f6aac5be0d141609da4c66be3996',
// isPrivate: true,
// script: `contract shorgc\\n{ \\nexport function hello(){return 1 } }`,
// path: '/data/tmp/hello.ypk',
// })
// 0430276215ff414e0047a532d4dea32048ad4ec60a729ce8e4248c98889d244c3b27b9549e5cb664ce324e2acac4a81590321f4196ca159cb577e06a3eb553ce6a
// 调用合约
// const data = client.executeContract('ControlProxy', 'getDoList', 'ss', false)
// const data = await client.applyNodeRole(
// '0430276215ff414e0047a532d4dea32048ad4ec60a729ce8e4248c98889d244c3b27b9549e5cb664ce324e2acac4a81590321f4196ca159cb577e06a3eb553ce6a',
// 'ContractProvider',
// )
// const data = await client.applyNodeRole('ContractInstanceManager')
// const data = client.startContractMultiPoint(
// '041016acfbc8f4068a24d38a99a1355449ba958f7e905d66617cec9eda311e3001f8d15a4440b6eb61d7b7bd94bb434b30a518623c1593540e7d32eb72fe8088e1,04a1bcfe25e973691fb055c5400d74cd722f05313149a89b9ae94fffe8a3f141a36193c43bf520f8260cac1a703a3b8f1f92e9c7c23ce61ef9a0cbecf670b07212,04870d138f9e6ffae2a0ae0b495c6d81ff6cca9c92c861156d7a5304558427588e05452394ce69c4894283d1b0ccf40ffdffbd13fa0884d9e559c355ac1672263b,',
// 6,
// 3,ß
// 'H2_2022-07-12-12_48_55_Auto.ypk',
// false,
// '',
// )
// const data = client.updateConfig('nodeName','Node_180')
// const code = `contract shorgc\\n{ \\nexport function hello(){return 1 } }`
// const data = client.startContract(code)
// const data = client.saveFile({
// content: 's',
// isAppend: false,
// isPrivate: true,
// path: '/data/tmp/hello.ypk',
// })
// const data = client.loadNodeConfig()
// const data = client.listContractProcess()
// const data = client.listNodes()
// const data = client.distributeContract(
// '0495d91b4dec0d14b067e8a3bd5d78f53f1389920284c0153547d9417ed37708f276e8ac3d8420e571106c9ab2c210192dd356b9757ea498fe578e5cc85182712e,',
// 'DoipDist-0.1.0.ypk',
// false,
// '04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb',
// )
// const data = client.killContractProcess('1759263594')
// const data = client.killAllContract()
// const data = await client.downloadContract(
// 'r',
// false,
// new Date().getTime(),
// )
print(JSON.stringify(data))
})()
// console.log(data)
</script>
<link rel="icon" type="image/svg+xml" href="favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
</head>
<body></body>
</html>