chore: build axios-fetch for test

This commit is contained in:
Nex Zhu 2023-03-18 19:55:44 +08:00
parent ec5099762e
commit 92129afd38
No known key found for this signature in database
GPG Key ID: 15C6254AD19362B4
3 changed files with 134 additions and 120 deletions

View File

@ -43,11 +43,10 @@
"prettier": "^2.7.1", "prettier": "^2.7.1",
"rollup": "^2.79.1", "rollup": "^2.79.1",
"rollup-plugin-dts": "^4.2.2", "rollup-plugin-dts": "^4.2.2",
"@rollup/plugin-node-resolve": "^15.0.1",
"rollup-plugin-terser": "^7.0.2", "rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.34.1", "rollup-plugin-typescript2": "^0.34.1",
"shx": "^0.3.4", "shx": "^0.3.4",
"sucrase": "^3.25.0", "sucrase": "^3.25.0",
"typescript": "^4.8.2" "typescript": "^4.8.2"
} }
} }

View File

@ -1,14 +1,23 @@
import type { RollupOptions } from '@rollup' import type { RollupOptions } from '@rollup'
import commonjs from '@rollup/plugin-commonjs'
import dts from 'rollup-plugin-dts' import dts from 'rollup-plugin-dts'
import { terser } from 'rollup-plugin-terser' import { terser } from 'rollup-plugin-terser'
import typescript from 'rollup-plugin-typescript2' import typescript from 'rollup-plugin-typescript2'
import commonjs from '@rollup/plugin-commonjs'
const pkg = require('./package.json') const pkg = require('./package.json')
const name = 'bdcontract' const name = 'bdcontract'
export default [ export default [
{
input: 'node_modules/@lifeomic/axios-fetch/src/index.js',
output: {
file: 'dist/axios-fetch.iife.js',
format: 'iife',
name: 'axiosFetch',
},
plugins: [commonjs()],
},
{ {
input: 'src/index.ts', input: 'src/index.ts',
output: [ output: [
@ -17,12 +26,12 @@ export default [
format: 'umd', format: 'umd',
name, name,
sourcemap: true, sourcemap: true,
globals:{ globals: {
"@daotl/cryptico":"cryptico", '@daotl/cryptico': 'cryptico',
"@lifeomic/axios-fetch":"axiosFetch", '@lifeomic/axios-fetch': 'axiosFetch',
"axios":"axios", axios: 'axios',
"sm-crypto":"smCrypto" 'sm-crypto': 'smCrypto',
} },
}, },
{ file: `${pkg.module}`, format: 'es', sourcemap: true }, { file: `${pkg.module}`, format: 'es', sourcemap: true },
{ {
@ -30,12 +39,12 @@ export default [
format: 'iife', format: 'iife',
name, name,
sourcemap: true, sourcemap: true,
globals:{ globals: {
"@daotl/cryptico":"cryptico", '@daotl/cryptico': 'cryptico',
"@lifeomic/axios-fetch":"axiosFetch", '@lifeomic/axios-fetch': 'axiosFetch',
"axios":"axios", axios: 'axios',
"sm-crypto":"smCrypto" 'sm-crypto': 'smCrypto',
} },
}, },
], ],
plugins: [ plugins: [
@ -43,7 +52,8 @@ export default [
tsconfig: 'tsconfig.build.json', tsconfig: 'tsconfig.build.json',
useTsconfigDeclarationDir: true, useTsconfigDeclarationDir: true,
}), }),
terser(),commonjs() terser(),
commonjs(),
], ],
}, },
{ {

View File

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