Commit 5ff86e01 authored by BigBigC's avatar BigBigC Committed by GitHub

init

parent 4a77dfde
# decentralized-ai-app-demo # AON 3D Clothing
It is a decentralized AI application demo using the AON SDK.
This template should help get you started developing with Vue 3 in Vite.
## Recommended IDE Setup
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur).
## Type Support for `.vue` Imports in TS
TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) to make the TypeScript language service aware of `.vue` types.
## Customize configuration
See [Vite Configuration Reference](https://vitejs.dev/config/).
## Project Setup
```sh
npm install
```
### Compile and Hot-Reload for Development
```sh
npm run dev
```
### Type-Check, Compile and Minify for Production
```sh
npm run build
```
/// <reference types="vite/client" />
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no" />
<title>AON 3D Clothing</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
{
"name": "AONET",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "run-p type-check \"build-only {@}\" --",
"preview": "vite preview",
"build-only": "vite build",
"type-check": "vue-tsc --build --force"
},
"dependencies": {
"aonweb": "^0.0.0",
"aos": "^2.3.4",
"axios": "^1.6.8",
"element-plus": "^2.7.5",
"vant": "^4.9.1",
"vue": "^3.4.21",
"vue-router": "^4.3.0",
"web-vitals": "^2.1.0",
"web3": "^4.9.0",
"web3-eth-accounts": "^4.1.2"
},
"devDependencies": {
"@tsconfig/node20": "^20.1.4",
"@types/aos": "^3.0.7",
"@types/node": "^20.12.5",
"@vitejs/plugin-vue": "^5.0.4",
"@vitejs/plugin-vue-jsx": "^3.1.0",
"@vue/tsconfig": "^0.5.1",
"npm-run-all2": "^6.1.2",
"typescript": "~5.4.0",
"vite": "^5.2.8",
"vite-plugin-commonjs": "^0.10.1",
"vite-plugin-vue-devtools": "^7.0.25",
"vue-tsc": "^2.0.11"
}
}
<script setup lang="ts">
import { RouterView } from 'vue-router'
</script>
<template>
<RouterView />
</template>
<style>
.container {
padding: 0 6.4vw 18.4vw;
margin: 0;
}
.bottom_btn {
width: 100%;
position: fixed;
bottom: 4.27vw;
left: 0;
padding: 0 6.4vw;
box-sizing: border-box;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
}
.bottom_btn uni-button {
margin: 0;
}
button {
display: flex;
justify-content: center;
align-items: center;
margin: 0;
border: none;
}
.uni-form-item .van-uploader__wrapper,
.uni-form-item .van-uploader__input-wrapper {
width: 100%;
}
</style>
/* color palette from <https://github.com/vuejs/theme> */
:root {
--vt-c-white: #ffffff;
--vt-c-white-soft: #f8f8f8;
--vt-c-white-mute: #f2f2f2;
--vt-c-black: #000000;
--vt-c-black-soft: #222222;
--vt-c-black-mute: #282828;
--vt-c-indigo: #2c3e50;
--vt-c-divider-light-1: rgba(60, 60, 60, 0.29);
--vt-c-divider-light-2: rgba(60, 60, 60, 0.12);
--vt-c-divider-dark-1: rgba(84, 84, 84, 0.65);
--vt-c-divider-dark-2: rgba(84, 84, 84, 0.48);
--vt-c-text-light-1: var(--vt-c-indigo);
--vt-c-text-light-2: rgba(60, 60, 60, 0.66);
--vt-c-text-dark-1: var(--vt-c-white);
--vt-c-text-dark-2: rgba(235, 235, 235, 0.64);
}
/* semantic color variables for this project */
:root {
--color-background: var(--vt-c-black);
--color-background-soft: var(--vt-c-white-soft);
--color-background-mute: var(--vt-c-white-mute);
--color-border: var(--vt-c-divider-light-2);
--color-border-hover: var(--vt-c-divider-light-1);
--color-heading: var(--vt-c-text-light-1);
--color-text: var(--vt-c-text-light-1);
--section-gap: 160px;
}
@media (prefers-color-scheme: dark) {
:root {
--color-background: var(--vt-c-black);
--color-background-soft: var(--vt-c-black-soft);
--color-background-mute: var(--vt-c-black-mute);
--color-border: var(--vt-c-divider-dark-2);
--color-border-hover: var(--vt-c-divider-dark-1);
--color-heading: var(--vt-c-text-dark-1);
--color-text: var(--vt-c-text-dark-2);
}
}
@font-face {
font-family: 'Roboto-Black';
src: url('./fonts/Roboto-Black.ttf');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'Roboto-Bold';
src: url('./fonts/Roboto-Bold.ttf');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'Roboto-Regular';
src: url('./fonts/Roboto-Regular.ttf');
font-weight: normal;
font-style: normal;
}
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
font-weight: normal;
}
body {
min-height: 100vh;
color: #000;
background: #fff;
transition:
color 0.5s,
background-color 0.5s;
line-height: 1.6;
font-family:
Adobe Heiti Std R,
sans-serif;
font-size: 16px;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
\ No newline at end of file
@import './base.css';
*{
scrollbar-width: none;
}
#app {
width: 100%;
height: 100%;
padding: 0;
margin: 0;
box-sizing: border-box;
}
a {
text-decoration: none;
color: rgba(255, 255, 255, 0.5);
transition: 0.4s;
padding: 3px;
}
input{
outline: none;
}
ul, li{
list-style: none;
padding: 0;
margin: 0;
}
@media (hover: hover) {
a:hover {
color: rgba(255, 255, 255, 1);
}
}
.fp-watermark{
display: none;
}
.fp-overflow{
height: 100vh;
}
\ No newline at end of file
<template>
<div class="custom-navbar">
<img src="../assets/logo_.png" class="logo" @click="goIndex"></img>
<div class="title">AON 3D Clothing</div>
<div class="right">
<div class="right_count">
<img src="../assets/icons/money.png" class="moneyIcon"></img>
<span class="count">120</span>
</div>
<img src="../assets/icons/user.png" v-if="!isUserPage" class="userIcon" @click="goUser"></img>
</div>
</div>
</template>
<script setup>
import {
defineProps,
ref,
onMounted,
computed
} from 'vue';
import { useRouter,useRoute } from 'vue-router'
const router = useRouter()
const route = useRoute()
const isUserPage = ref(false);
const props = defineProps({
title: {
type: String,
default: ''
},
showBackIcon: {
type: Boolean,
default: true
}
});
const goIndex = () => {
router.push('/')
};
const goUser = () => {
router.push('/user')
};
const checkIfUserPage = () => {
isUserPage.value = route.path === '/user'
};
onMounted(() => {
checkIfUserPage();
});
</script>
<style scoped>
.custom-navbar {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
height: 13.33vw;
padding: 0 6.4vw;
background-color: #fff;
}
.logo {
width: 10.67vw;
height: 4.8vw;
}
.title {
flex: 1;
font-family: Roboto-Black;
font-weight: 900;
font-size: 4.8vw;
color: #000000;
text-align: left;
font-style: normal;
text-transform: none;
margin-left: 2.13vw;
}
.right {
min-width: 16.8vw;
height: 6.4vw;
padding: 0 1.07vw;
background: #000000;
border-radius: 10.67vw;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
}
.right_count {
display: flex;
flex-direction: row;
align-items: center;
}
.right .right_count .moneyIcon,
.right .userIcon {
height: 4.27vw;
width: 4.27vw;
margin-right: 1.07vw;
}
.right .userIcon {
border-radius: 100%;
margin-right: 0;
margin-left: 1.07vw;
}
.right .count {
font-family: Roboto, Roboto;
font-weight: bold;
font-size: 2.67vw;
color: #FFFFFF;
text-align: left;
font-style: normal;
text-transform: none;
}
</style>
<template>
<div class="loading" v-if="showLoading">
<div class="running-con">
<img src="../assets/images/running.gif" mode=""></img>
<p>RUNNING...</p>
</div>
</div>
</template>
<script setup>
import {
defineProps,
defineEmits
} from 'vue';
const props = defineProps({
showLoading: {
type: Boolean,
default: false
}
});
</script>
<style>
.loading{
position: fixed;
top: 0;
left: 0;
z-index: 100;
height: 100%;
width: 100%;
background: #FFFFFF;
opacity: 0.93;
display: flex;
justify-content: center;
align-items: center;
}
.running-con{
width: 56vw;
height: 25.07vw;
background: #000000;
border-radius: 4.27vw;
border: .13vw solid #707070;
display: flex;
justify-content: center;
align-items: flex-end;
position: relative;
padding: 5.6vw 0;
box-sizing: border-box;
}
.running-con img{
width: 22.4vw;
height: 38.4vw;
position: absolute;
left: 50%;
transform: translateX(-50%);
top: -28vw;
}
.running-con p{
font-family: Roboto-Bold;
font-weight: bold;
font-size: 3.73vw;
color: #FFFFFF;
text-align: center;
font-style: normal;
text-transform: none;
/* margin-top: 32rpx; */
}
</style>
\ No newline at end of file
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const U=require("web3"),d=require("web3-eth-accounts"),f={TYPE_TG:1,TYPE_FP:2};let l=class{constructor({rpc_url:e="https://dev.rpc.aonet.ai",type:s=f.TYPE_FP,server:n="https://dev.rpc.aonet.ai",password:i="",storeage_url:o="",timeout:r=3e3,force_aon:c=!0}={}){if(this.rpc_url=e,this.type=s,this.server=n,this.password=i,this.storeage_url=o,this.timeout=r,this.force_aon=c,this.type==f.TYPE_FP&&this.storeage_url=="")throw new Error("storeage_url must be set when type = TYPE_FP")}static get LoginTypes(){return f}};var w;(function(t){t.NUMBER="NUMBER_NUMBER",t.HEX="NUMBER_HEX",t.STR="NUMBER_STR",t.BIGINT="NUMBER_BIGINT"})(w||(w={}));var y;(function(t){t.HEX="BYTES_HEX",t.UINT8ARRAY="BYTES_UINT8ARRAY"})(y||(y={}));w.BIGINT,y.HEX;w.HEX,y.HEX;var v;(function(t){t.EARLIEST="earliest",t.LATEST="latest",t.PENDING="pending",t.SAFE="safe",t.FINALIZED="finalized"})(v||(v={}));var P;(function(t){t.chainstart="chainstart",t.frontier="frontier",t.homestead="homestead",t.dao="dao",t.tangerineWhistle="tangerineWhistle",t.spuriousDragon="spuriousDragon",t.byzantium="byzantium",t.constantinople="constantinople",t.petersburg="petersburg",t.istanbul="istanbul",t.muirGlacier="muirGlacier",t.berlin="berlin",t.london="london",t.altair="altair",t.arrowGlacier="arrowGlacier",t.grayGlacier="grayGlacier",t.bellatrix="bellatrix",t.merge="merge",t.capella="capella",t.shanghai="shanghai"})(P||(P={}));var E=function(t,e,s,n){function i(o){return o instanceof s?o:new s(function(r){r(o)})}return new(s||(s=Promise))(function(o,r){function c(h){try{p(n.next(h))}catch(m){r(m)}}function a(h){try{p(n.throw(h))}catch(m){r(m)}}function p(h){h.done?o(h.value):i(h.value).then(c,a)}p((n=n.apply(t,e||[])).next())})};const I=Symbol.for("web3/base-provider");class T{static isWeb3Provider(e){return e instanceof T||!!(e&&e[I])}get[I](){return!0}send(e,s){this.request(e).then(n=>{s(null,n)}).catch(n=>{s(n)})}sendAsync(e){return E(this,void 0,void 0,function*(){return this.request(e)})}asEIP1193Provider(){const e=Object.create(this),s=e.request;return e.request=function(i){return E(this,void 0,void 0,function*(){return(yield s(i)).result})},e.asEIP1193Provider=void 0,e}}class q{constructor(e=new Options){try{this.options=e}catch(s){throw s}}async setItem(e,s,n){try{let i=localStorage.getItem("fingerprint"),o={key:e+"_"+i,value:s},r=localStorage.getItem("token");r=r.replace(/^\"|\"$/g,"");let c={Authorization:"Bearer "+r},a=this.options.storeage_url+"/kvapi/v1/storage/set";const h=await(await fetch(a,{method:"POST",headers:c,body:JSON.stringify(o)})).json();h&&h.success?n(null):n(new Error(JSON.stringify(h)||""))}catch(i){n(i)}}async getItem(e,s){try{let n=localStorage.getItem("token");n=n.replace(/^\"|\"$/g,"");let i={Authorization:"Bearer "+n},o=localStorage.getItem("fingerprint");e=e+"_"+o;let r=this.options.storeage_url+"/kvapi/v1/storage/get?key="+e;const a=await(await fetch(r,{method:"GET",headers:i})).json();a&&a.success?s(null,a.value):s(new Error(JSON.stringify(a)||""),null)}catch(n){s(n,null)}}}let g;const D=new Uint8Array(16);function R(){if(!g&&(g=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!g))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return g(D)}const u=[];for(let t=0;t<256;++t)u.push((t+256).toString(16).slice(1));function x(t,e=0){return u[t[e+0]]+u[t[e+1]]+u[t[e+2]]+u[t[e+3]]+"-"+u[t[e+4]]+u[t[e+5]]+"-"+u[t[e+6]]+u[t[e+7]]+"-"+u[t[e+8]]+u[t[e+9]]+"-"+u[t[e+10]]+u[t[e+11]]+u[t[e+12]]+u[t[e+13]]+u[t[e+14]]+u[t[e+15]]}const Y=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),b={randomUUID:Y};function G(t,e,s){if(b.randomUUID&&!e&&!t)return b.randomUUID();t=t||{};const n=t.random||(t.rng||R)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,x(n)}class B extends T{constructor(e=new l){try{super(),this.options=e,this.isAON=!0,window.Telegram&&window.Telegram.WebApp&&window.Telegram.WebApp.initData&&(e.type=l.LoginTypes.TYPE_TG),e.type==l.LoginTypes.TYPE_TG?(this.webapp=window.Telegram.WebApp,this.storage=window.Telegram.WebApp.CloudStorage):e.type==l.LoginTypes.TYPE_FP&&(this.storage=new q(e)),this.keystore=null,this.account=null,this._nextId=0,this.provider=new U.Web3.providers.HttpProvider(e.rpc_url)}catch(s){throw s}}async _getPassword(){return await new Promise((s,n)=>{this.storage.getItem("aon_web_sdk_password",(i,o)=>{i&&n(i),s(o)})})}async check(e){try{let s={};if(e.type==l.LoginTypes.TYPE_TG)s={platform:"telegram",initData:this.webapp.initData};else if(e.type==l.LoginTypes.TYPE_FP){let r=localStorage.getItem("fingerprint");r||(r=await new Promise((c,a)=>{const p=G();c(p)}),localStorage.setItem("fingerprint",r)),s={platform:"fingerprint",visitorId:r}}let n=e.server+"/api/v1/user/check";const o=await(await fetch(n,{method:"POST",body:JSON.stringify(s)})).json();if(o.code==0&&o.data){const r=o.data.token;return r&&this.setAuth(r),o.data}return o}catch(s){throw s}}async setPassword(e){await new Promise((s,n)=>{this.storage.setItem("aon_web_sdk_password",e,i=>{i&&n(i),s()})})}generateRandomPassword(e){const s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+{}|:<>?-=[];',./";let n="";for(let i=0;i<e;i++){const o=Math.floor(Math.random()*s.length);n+=s[o]}return n}async getAuth(){return this.options.type==l.LoginTypes.TYPE_TG?await new Promise((s,n)=>{this.storage.getItem("token",(i,o)=>{i&&n(i),s(o)})}):localStorage.getItem("token")}async setAuth(e){this.options.type==l.LoginTypes.TYPE_TG?await new Promise((s,n)=>{this.storage.setItem("token",JSON.stringify(e),i=>{i&&n(i),s()})}):localStorage.setItem("token",e)}async createUserToServer(e,s){let n={keystore:JSON.stringify(e),signature:s},i=await this.getAuth();i=i.replace(/^\"|\"$/g,"");let o={Authorization:"Bearer "+i},r=this.options.server+"/api/v1/user/create";return await(await fetch(r,{method:"POST",headers:o,body:JSON.stringify(n)})).json()}async createUser(){let e=this.generateRandomPassword(20),s=d.create(),n=await d.encrypt(s.privateKey,e),o=d.sign(JSON.stringify(n),s.privateKey).signature,r=await this.createUserToServer(n,o);if(r.code==0)return await this.setPassword(e),{keystore:n,account:s};throw new Error(r.error||r.msg)}async loadKeystore(){try{let e=await this.check(this.options);if(e.code)throw new Error(e.msg||e.error);if(e.isNewUser){let n=await this.createUser();this.account=n.account,this.keystore=n.keystore;return}let s=await this._getPassword();this.keystore=JSON.parse(e.keystore),this.account=await d.decrypt(this.keystore,s)}catch(e){console.log("loadKeystore error",e)}}request(e){return console.log("request",e),e.method=="eth_accounts"||e.method=="eth_requestAccounts"?new Promise((s,n)=>{try{if(this.account){s([this.account.address]);return}s([])}catch(i){n(i)}}):e.method=="eth_sendTransaction"?(e.method="eth_signTransaction",new Promise((s,n)=>{let i=e.params&&e.params.length&&e.params[0];i.gasLimit||(i.gasLimit=5e5),this.provider.request({method:"eth_chainId"}).then(o=>{console.log("eth_chainId ",o);let r=100199;o.result&&(r=parseInt(o.result,16)),i.chainId||(i.chainId=r),i.v=27+i.chainId*2+8,this.provider.request({method:"eth_getTransactionCount",params:[this.account.address]}).then(c=>{console.log("eth_getTransactionCount ",c),i.nonce||(i.nonce=c.result),console.log("before signTransaction param",i),d.signTransaction(new d.Transaction(i),this.account.privateKey).then(a=>{if(console.log("signTransaction ",a),a&&a.rawTransaction&&a.rawTransaction.length){const p={method:"eth_sendRawTransaction",params:[a.rawTransaction],id:this._nextId++,jsonrpc:"2.0"};this.provider.request(p).then(h=>{console.log("eth_sendRawTransaction ",h),s(h)}).catch(h=>{console.log("eth_sendRawTransaction error",h),n(h)})}else n(new Error("signTransaction error"))}).catch(a=>{console.log("signTransaction error",a),n(a)})}).catch(c=>{console.log("eth_getTransactionCount error",c),n(c)})}).catch(o=>{console.log("eth_chainId error",o),n(o)})})):this.provider.request(e)}async send(e,s){console.log("send",e,s);const n={method:e,params:s,id:this._nextId++,jsonrpc:"2.0"};return this.request(n)}}async function _(t=new l){console.log("detectEthereumProvider in");let e=!1;return await new Promise(async(n,i)=>{if(window.ethereum){if(t.force_aon&&!window.ethereum.isAON){let r=await o(t);n(r)}n(window.ethereum)}else{let r=await o(t);n(r)}async function o(r){if(console.log("createProvider in"),e)return;e=!0;const c=new B(r);return await c.loadKeystore(),window.ethereum=c,console.log("createProvider instance",c),c}})}class A{constructor(e=new l){this.options=e}async login(){return(await _(this.options)).request({method:"eth_accounts"})}}const L=1,S=2,W={1:"/api",2:"/jwt"};class N{constructor(e){if(!(e&&e.auth&&e.auth.length))throw new Error("options.auth is not found");this.auth=e.auth,this.options=e,this.init()}init(){let e="/v1";this.options&&this.options.api_version&&this.options.api_version.length&&(e=this.options.api_version),this.auth_type=this.parseAuthType(this.auth),this.path=W[this.auth_type]+e}parseAuthType(e){const s=this.decodeBase64(e);return console.log("parseAuthType",s),s.indexOf("JWT")>-1?S:L}decodeBase64(e){return typeof window<"u"&&typeof window.atob=="function"?window.atob(e):Buffer.from(e,"base64").toString("utf-8")}async prediction(e,s){try{let n="https://api.aonet.ai";this.options&&this.options.host&&this.options.host.length&&(n=this.options.host);const i=n+this.path+e;let o={apikey:this.auth};if(this.auth_type==S&&(o={Authorization:"Bearer "+this.auth}),this.options&&this.options.headers)for(const a in this.options.headers)a!="apikey"&&a!="Authorization"&&(o[a]=this.options.headers[a]);const r=await fetch(i,{method:"POST",headers:o,body:JSON.stringify(s)});return r?await r.json():{task:{is_success:!1,task_error:"network error",exec_code:"5000"}}}catch(n){console.error("Error:",n)}}}(function(t,e){typeof define=="function"&&define.amd?define(["web3","web3-eth-accounts"],e):typeof module=="object"&&module.exports?module.exports=e(require("web3"),require("web3-eth-accounts")):t.aonweb=e(t.Web3,t.Web3EthAccounts)})(typeof self<"u"?self:void 0,function(t,e){return{Options:l,User:A,AI:N,detectEthereumProvider:_}});exports.AI=N;exports.Options=l;exports.User=A;exports.detectEthereumProvider=_;
import { Web3 as S } from "web3";
import { create as A, encrypt as N, sign as U, decrypt as D, signTransaction as R, Transaction as x } from "web3-eth-accounts";
const m = {
TYPE_TG: 1,
TYPE_FP: 2
};
let l = class {
constructor({
rpc_url: t = "https://dev.rpc.aonet.ai",
type: s = m.TYPE_FP,
server: n = "https://dev.rpc.aonet.ai",
password: i = "",
storeage_url: o = "",
timeout: r = 3e3,
force_aon: c = !0
} = {}) {
if (this.rpc_url = t, this.type = s, this.server = n, this.password = i, this.storeage_url = o, this.timeout = r, this.force_aon = c, this.type == m.TYPE_FP && this.storeage_url == "")
throw new Error("storeage_url must be set when type = TYPE_FP");
}
static get LoginTypes() {
return m;
}
};
var g;
(function(e) {
e.NUMBER = "NUMBER_NUMBER", e.HEX = "NUMBER_HEX", e.STR = "NUMBER_STR", e.BIGINT = "NUMBER_BIGINT";
})(g || (g = {}));
var w;
(function(e) {
e.HEX = "BYTES_HEX", e.UINT8ARRAY = "BYTES_UINT8ARRAY";
})(w || (w = {}));
g.BIGINT, w.HEX;
g.HEX, w.HEX;
var _;
(function(e) {
e.EARLIEST = "earliest", e.LATEST = "latest", e.PENDING = "pending", e.SAFE = "safe", e.FINALIZED = "finalized";
})(_ || (_ = {}));
var T;
(function(e) {
e.chainstart = "chainstart", e.frontier = "frontier", e.homestead = "homestead", e.dao = "dao", e.tangerineWhistle = "tangerineWhistle", e.spuriousDragon = "spuriousDragon", e.byzantium = "byzantium", e.constantinople = "constantinople", e.petersburg = "petersburg", e.istanbul = "istanbul", e.muirGlacier = "muirGlacier", e.berlin = "berlin", e.london = "london", e.altair = "altair", e.arrowGlacier = "arrowGlacier", e.grayGlacier = "grayGlacier", e.bellatrix = "bellatrix", e.merge = "merge", e.capella = "capella", e.shanghai = "shanghai";
})(T || (T = {}));
var v = function(e, t, s, n) {
function i(o) {
return o instanceof s ? o : new s(function(r) {
r(o);
});
}
return new (s || (s = Promise))(function(o, r) {
function c(h) {
try {
p(n.next(h));
} catch (y) {
r(y);
}
}
function a(h) {
try {
p(n.throw(h));
} catch (y) {
r(y);
}
}
function p(h) {
h.done ? o(h.value) : i(h.value).then(c, a);
}
p((n = n.apply(e, t || [])).next());
});
};
const P = Symbol.for("web3/base-provider");
class f {
static isWeb3Provider(t) {
return t instanceof f || !!(t && t[P]);
}
// To match an object "instanceof" does not work if
// matcher class and object is using different package versions
// to overcome this bottleneck used this approach.
// The symbol value for one string will always remain same regardless of package versions
// eslint-disable-next-line class-methods-use-this
get [P]() {
return !0;
}
/**
* @deprecated Please use `.request` instead.
* @param payload - Request Payload
* @param callback - Callback
*/
send(t, s) {
this.request(t).then((n) => {
s(null, n);
}).catch((n) => {
s(n);
});
}
/**
* @deprecated Please use `.request` instead.
* @param payload - Request Payload
*/
sendAsync(t) {
return v(this, void 0, void 0, function* () {
return this.request(t);
});
}
/**
* Modify the return type of the request method to be fully compatible with EIP-1193
*
* [deprecated] In the future major releases (\>= v5) all providers are supposed to be fully compatible with EIP-1193.
* So this method will not be needed and would not be available in the future.
*
* @returns A new instance of the provider with the request method fully compatible with EIP-1193
*
* @example
* ```ts
* const provider = new Web3HttpProvider('http://localhost:8545');
* const fullyCompatibleProvider = provider.asEIP1193Provider();
* const result = await fullyCompatibleProvider.request({ method: 'eth_getBalance' });
* console.log(result); // '0x0234c8a3397aab58' or something like that
* ```
*/
asEIP1193Provider() {
const t = Object.create(this), s = t.request;
return t.request = function(i) {
return v(this, void 0, void 0, function* () {
return (yield s(i)).result;
});
}, t.asEIP1193Provider = void 0, t;
}
}
class q {
constructor(t = new Options()) {
try {
this.options = t;
} catch (s) {
throw s;
}
}
async setItem(t, s, n) {
try {
let i = localStorage.getItem("fingerprint"), o = {
key: t + "_" + i,
value: s
}, r = localStorage.getItem("token");
r = r.replace(/^\"|\"$/g, "");
let c = {
Authorization: "Bearer " + r
}, a = this.options.storeage_url + "/kvapi/v1/storage/set";
const h = await (await fetch(a, {
method: "POST",
headers: c,
body: JSON.stringify(o)
})).json();
h && h.success ? n(null) : n(new Error(JSON.stringify(h) || ""));
} catch (i) {
n(i);
}
}
async getItem(t, s) {
try {
let n = localStorage.getItem("token");
n = n.replace(/^\"|\"$/g, "");
let i = {
Authorization: "Bearer " + n
}, o = localStorage.getItem("fingerprint");
t = t + "_" + o;
let r = this.options.storeage_url + "/kvapi/v1/storage/get?key=" + t;
const a = await (await fetch(r, {
method: "GET",
headers: i
})).json();
a && a.success ? s(null, a.value) : s(new Error(JSON.stringify(a) || ""), null);
} catch (n) {
s(n, null);
}
}
}
let d;
const Y = new Uint8Array(16);
function G() {
if (!d && (d = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !d))
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
return d(Y);
}
const u = [];
for (let e = 0; e < 256; ++e)
u.push((e + 256).toString(16).slice(1));
function B(e, t = 0) {
return u[e[t + 0]] + u[e[t + 1]] + u[e[t + 2]] + u[e[t + 3]] + "-" + u[e[t + 4]] + u[e[t + 5]] + "-" + u[e[t + 6]] + u[e[t + 7]] + "-" + u[e[t + 8]] + u[e[t + 9]] + "-" + u[e[t + 10]] + u[e[t + 11]] + u[e[t + 12]] + u[e[t + 13]] + u[e[t + 14]] + u[e[t + 15]];
}
const L = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), E = {
randomUUID: L
};
function W(e, t, s) {
if (E.randomUUID && !t && !e)
return E.randomUUID();
e = e || {};
const n = e.random || (e.rng || G)();
return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, B(n);
}
class J extends f {
constructor(t = new l()) {
try {
super(), this.options = t, this.isAON = !0, window.Telegram && window.Telegram.WebApp && window.Telegram.WebApp.initData && (t.type = l.LoginTypes.TYPE_TG), t.type == l.LoginTypes.TYPE_TG ? (this.webapp = window.Telegram.WebApp, this.storage = window.Telegram.WebApp.CloudStorage) : t.type == l.LoginTypes.TYPE_FP && (this.storage = new q(t)), this.keystore = null, this.account = null, this._nextId = 0, this.provider = new S.providers.HttpProvider(t.rpc_url);
} catch (s) {
throw s;
}
}
async _getPassword() {
return await new Promise((s, n) => {
this.storage.getItem("aon_web_sdk_password", (i, o) => {
i && n(i), s(o);
});
});
}
async check(t) {
try {
let s = {};
if (t.type == l.LoginTypes.TYPE_TG)
s = {
platform: "telegram",
initData: this.webapp.initData
};
else if (t.type == l.LoginTypes.TYPE_FP) {
let r = localStorage.getItem("fingerprint");
r || (r = await new Promise((c, a) => {
const p = W();
c(p);
}), localStorage.setItem("fingerprint", r)), s = {
platform: "fingerprint",
visitorId: r
};
}
let n = t.server + "/api/v1/user/check";
const o = await (await fetch(n, {
method: "POST",
body: JSON.stringify(s)
})).json();
if (o.code == 0 && o.data) {
const r = o.data.token;
return r && this.setAuth(r), o.data;
}
return o;
} catch (s) {
throw s;
}
}
async setPassword(t) {
await new Promise((s, n) => {
this.storage.setItem("aon_web_sdk_password", t, (i) => {
i && n(i), s();
});
});
}
generateRandomPassword(t) {
const s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+{}|:<>?-=[];',./";
let n = "";
for (let i = 0; i < t; i++) {
const o = Math.floor(Math.random() * s.length);
n += s[o];
}
return n;
}
async getAuth() {
return this.options.type == l.LoginTypes.TYPE_TG ? await new Promise((s, n) => {
this.storage.getItem("token", (i, o) => {
i && n(i), s(o);
});
}) : localStorage.getItem("token");
}
async setAuth(t) {
this.options.type == l.LoginTypes.TYPE_TG ? await new Promise((s, n) => {
this.storage.setItem("token", JSON.stringify(t), (i) => {
i && n(i), s();
});
}) : localStorage.setItem("token", t);
}
async createUserToServer(t, s) {
let n = {
keystore: JSON.stringify(t),
signature: s
}, i = await this.getAuth();
i = i.replace(/^\"|\"$/g, "");
let o = {
Authorization: "Bearer " + i
}, r = this.options.server + "/api/v1/user/create";
return await (await fetch(r, {
method: "POST",
headers: o,
body: JSON.stringify(n)
})).json();
}
async createUser() {
let t = this.generateRandomPassword(20), s = A(), n = await N(s.privateKey, t), o = U(JSON.stringify(n), s.privateKey).signature, r = await this.createUserToServer(n, o);
if (r.code == 0)
return await this.setPassword(t), {
keystore: n,
account: s
};
throw new Error(r.error || r.msg);
}
async loadKeystore() {
try {
let t = await this.check(this.options);
if (t.code)
throw new Error(t.msg || t.error);
if (t.isNewUser) {
let n = await this.createUser();
this.account = n.account, this.keystore = n.keystore;
return;
}
let s = await this._getPassword();
this.keystore = JSON.parse(t.keystore), this.account = await D(this.keystore, s);
} catch (t) {
console.log("loadKeystore error", t);
}
}
request(t) {
return console.log("request", t), t.method == "eth_accounts" || t.method == "eth_requestAccounts" ? new Promise((s, n) => {
try {
if (this.account) {
s([this.account.address]);
return;
}
s([]);
} catch (i) {
n(i);
}
}) : t.method == "eth_sendTransaction" ? (t.method = "eth_signTransaction", new Promise((s, n) => {
let i = t.params && t.params.length && t.params[0];
i.gasLimit || (i.gasLimit = 5e5), this.provider.request({ method: "eth_chainId" }).then((o) => {
console.log("eth_chainId ", o);
let r = 100199;
o.result && (r = parseInt(o.result, 16)), i.chainId || (i.chainId = r), i.v = 27 + i.chainId * 2 + 8, this.provider.request({ method: "eth_getTransactionCount", params: [this.account.address] }).then((c) => {
console.log("eth_getTransactionCount ", c), i.nonce || (i.nonce = c.result), console.log("before signTransaction param", i), R(new x(i), this.account.privateKey).then((a) => {
if (console.log("signTransaction ", a), a && a.rawTransaction && a.rawTransaction.length) {
const p = {
method: "eth_sendRawTransaction",
params: [a.rawTransaction],
id: this._nextId++,
jsonrpc: "2.0"
};
this.provider.request(p).then((h) => {
console.log("eth_sendRawTransaction ", h), s(h);
}).catch((h) => {
console.log("eth_sendRawTransaction error", h), n(h);
});
} else
n(new Error("signTransaction error"));
}).catch((a) => {
console.log("signTransaction error", a), n(a);
});
}).catch((c) => {
console.log("eth_getTransactionCount error", c), n(c);
});
}).catch((o) => {
console.log("eth_chainId error", o), n(o);
});
})) : this.provider.request(t);
}
async send(t, s) {
console.log("send", t, s);
const n = {
method: t,
params: s,
id: this._nextId++,
jsonrpc: "2.0"
};
return this.request(n);
}
}
async function b(e = new l()) {
console.log("detectEthereumProvider in");
let t = !1;
return await new Promise(async (n, i) => {
if (window.ethereum) {
if (e.force_aon && !window.ethereum.isAON) {
let r = await o(e);
n(r);
}
n(window.ethereum);
} else {
let r = await o(e);
n(r);
}
async function o(r) {
if (console.log("createProvider in"), t)
return;
t = !0;
const c = new J(r);
return await c.loadKeystore(), window.ethereum = c, console.log("createProvider instance", c), c;
}
});
}
class j {
constructor(t = new l()) {
this.options = t;
}
async login() {
return (await b(this.options)).request({ method: "eth_accounts" });
}
}
const z = 1, I = 2, k = {
1: "/api",
2: "/jwt"
};
class O {
constructor(t) {
if (!(t && t.auth && t.auth.length))
throw new Error("options.auth is not found");
this.auth = t.auth, this.options = t, this.init();
}
init() {
let t = "/v1";
this.options && this.options.api_version && this.options.api_version.length && (t = this.options.api_version), this.auth_type = this.parseAuthType(this.auth), this.path = k[this.auth_type] + t;
}
parseAuthType(t) {
const s = this.decodeBase64(t);
return console.log("parseAuthType", s), s.indexOf("JWT") > -1 ? I : z;
}
decodeBase64(t) {
return typeof window < "u" && typeof window.atob == "function" ? window.atob(t) : Buffer.from(t, "base64").toString("utf-8");
}
async prediction(t, s) {
try {
let n = "https://api.aonet.ai";
this.options && this.options.host && this.options.host.length && (n = this.options.host);
const i = n + this.path + t;
let o = {
apikey: this.auth
};
if (this.auth_type == I && (o = {
Authorization: "Bearer " + this.auth
}), this.options && this.options.headers)
for (const a in this.options.headers)
a != "apikey" && a != "Authorization" && (o[a] = this.options.headers[a]);
const r = await fetch(i, {
method: "POST",
headers: o,
body: JSON.stringify(s)
});
return r ? await r.json() : {
task: {
is_success: !1,
task_error: "network error",
exec_code: "5000"
}
};
} catch (n) {
console.error("Error:", n);
}
}
}
(function(e, t) {
typeof define == "function" && define.amd ? define(["web3", "web3-eth-accounts"], t) : typeof module == "object" && module.exports ? module.exports = t(require("web3"), require("web3-eth-accounts")) : e.aonweb = t(e.Web3, e.Web3EthAccounts);
})(typeof self < "u" ? self : void 0, function(e, t) {
return {
Options: l,
User: j,
AI: O,
detectEthereumProvider: b
};
});
export {
O as AI,
l as Options,
j as User,
b as detectEthereumProvider
};
var aonweb=function(d,D,g){"use strict";const f={TYPE_TG:1,TYPE_FP:2};let l=class{constructor({rpc_url:e="https://dev.rpc.aonet.ai",type:i=f.TYPE_FP,server:n="https://dev.rpc.aonet.ai",password:s="",storeage_url:o="",timeout:r=3e3,force_aon:c=!0}={}){if(this.rpc_url=e,this.type=i,this.server=n,this.password=s,this.storeage_url=o,this.timeout=r,this.force_aon=c,this.type==f.TYPE_FP&&this.storeage_url=="")throw new Error("storeage_url must be set when type = TYPE_FP")}static get LoginTypes(){return f}};var w;(function(t){t.NUMBER="NUMBER_NUMBER",t.HEX="NUMBER_HEX",t.STR="NUMBER_STR",t.BIGINT="NUMBER_BIGINT"})(w||(w={}));var y;(function(t){t.HEX="BYTES_HEX",t.UINT8ARRAY="BYTES_UINT8ARRAY"})(y||(y={})),w.BIGINT,y.HEX,w.HEX,y.HEX;var P;(function(t){t.EARLIEST="earliest",t.LATEST="latest",t.PENDING="pending",t.SAFE="safe",t.FINALIZED="finalized"})(P||(P={}));var I;(function(t){t.chainstart="chainstart",t.frontier="frontier",t.homestead="homestead",t.dao="dao",t.tangerineWhistle="tangerineWhistle",t.spuriousDragon="spuriousDragon",t.byzantium="byzantium",t.constantinople="constantinople",t.petersburg="petersburg",t.istanbul="istanbul",t.muirGlacier="muirGlacier",t.berlin="berlin",t.london="london",t.altair="altair",t.arrowGlacier="arrowGlacier",t.grayGlacier="grayGlacier",t.bellatrix="bellatrix",t.merge="merge",t.capella="capella",t.shanghai="shanghai"})(I||(I={}));var b=function(t,e,i,n){function s(o){return o instanceof i?o:new i(function(r){r(o)})}return new(i||(i=Promise))(function(o,r){function c(u){try{p(n.next(u))}catch(v){r(v)}}function a(u){try{p(n.throw(u))}catch(v){r(v)}}function p(u){u.done?o(u.value):s(u.value).then(c,a)}p((n=n.apply(t,e||[])).next())})};const E=Symbol.for("web3/base-provider");class T{static isWeb3Provider(e){return e instanceof T||!!(e&&e[E])}get[E](){return!0}send(e,i){this.request(e).then(n=>{i(null,n)}).catch(n=>{i(n)})}sendAsync(e){return b(this,void 0,void 0,function*(){return this.request(e)})}asEIP1193Provider(){const e=Object.create(this),i=e.request;return e.request=function(s){return b(this,void 0,void 0,function*(){return(yield i(s)).result})},e.asEIP1193Provider=void 0,e}}class R{constructor(e=new Options){try{this.options=e}catch(i){throw i}}async setItem(e,i,n){try{let s=localStorage.getItem("fingerprint"),o={key:e+"_"+s,value:i},r=localStorage.getItem("token");r=r.replace(/^\"|\"$/g,"");let c={Authorization:"Bearer "+r},a=this.options.storeage_url+"/kvapi/v1/storage/set";const u=await(await fetch(a,{method:"POST",headers:c,body:JSON.stringify(o)})).json();u&&u.success?n(null):n(new Error(JSON.stringify(u)||""))}catch(s){n(s)}}async getItem(e,i){try{let n=localStorage.getItem("token");n=n.replace(/^\"|\"$/g,"");let s={Authorization:"Bearer "+n},o=localStorage.getItem("fingerprint");e=e+"_"+o;let r=this.options.storeage_url+"/kvapi/v1/storage/get?key="+e;const a=await(await fetch(r,{method:"GET",headers:s})).json();a&&a.success?i(null,a.value):i(new Error(JSON.stringify(a)||""),null)}catch(n){i(n,null)}}}let m;const q=new Uint8Array(16);function Y(){if(!m&&(m=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!m))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return m(q)}const h=[];for(let t=0;t<256;++t)h.push((t+256).toString(16).slice(1));function G(t,e=0){return h[t[e+0]]+h[t[e+1]]+h[t[e+2]]+h[t[e+3]]+"-"+h[t[e+4]]+h[t[e+5]]+"-"+h[t[e+6]]+h[t[e+7]]+"-"+h[t[e+8]]+h[t[e+9]]+"-"+h[t[e+10]]+h[t[e+11]]+h[t[e+12]]+h[t[e+13]]+h[t[e+14]]+h[t[e+15]]}const S={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function W(t,e,i){if(S.randomUUID&&!e&&!t)return S.randomUUID();t=t||{};const n=t.random||(t.rng||Y)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,G(n)}class x extends T{constructor(e=new l){try{super(),this.options=e,this.isAON=!0,window.Telegram&&window.Telegram.WebApp&&window.Telegram.WebApp.initData&&(e.type=l.LoginTypes.TYPE_TG),e.type==l.LoginTypes.TYPE_TG?(this.webapp=window.Telegram.WebApp,this.storage=window.Telegram.WebApp.CloudStorage):e.type==l.LoginTypes.TYPE_FP&&(this.storage=new R(e)),this.keystore=null,this.account=null,this._nextId=0,this.provider=new D.Web3.providers.HttpProvider(e.rpc_url)}catch(i){throw i}}async _getPassword(){return await new Promise((i,n)=>{this.storage.getItem("aon_web_sdk_password",(s,o)=>{s&&n(s),i(o)})})}async check(e){try{let i={};if(e.type==l.LoginTypes.TYPE_TG)i={platform:"telegram",initData:this.webapp.initData};else if(e.type==l.LoginTypes.TYPE_FP){let r=localStorage.getItem("fingerprint");r||(r=await new Promise((c,a)=>{const p=W();c(p)}),localStorage.setItem("fingerprint",r)),i={platform:"fingerprint",visitorId:r}}let n=e.server+"/api/v1/user/check";const o=await(await fetch(n,{method:"POST",body:JSON.stringify(i)})).json();if(o.code==0&&o.data){const r=o.data.token;return r&&this.setAuth(r),o.data}return o}catch(i){throw i}}async setPassword(e){await new Promise((i,n)=>{this.storage.setItem("aon_web_sdk_password",e,s=>{s&&n(s),i()})})}generateRandomPassword(e){const i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+{}|:<>?-=[];',./";let n="";for(let s=0;s<e;s++){const o=Math.floor(Math.random()*i.length);n+=i[o]}return n}async getAuth(){return this.options.type==l.LoginTypes.TYPE_TG?await new Promise((i,n)=>{this.storage.getItem("token",(s,o)=>{s&&n(s),i(o)})}):localStorage.getItem("token")}async setAuth(e){this.options.type==l.LoginTypes.TYPE_TG?await new Promise((i,n)=>{this.storage.setItem("token",JSON.stringify(e),s=>{s&&n(s),i()})}):localStorage.setItem("token",e)}async createUserToServer(e,i){let n={keystore:JSON.stringify(e),signature:i},s=await this.getAuth();s=s.replace(/^\"|\"$/g,"");let o={Authorization:"Bearer "+s},r=this.options.server+"/api/v1/user/create";return await(await fetch(r,{method:"POST",headers:o,body:JSON.stringify(n)})).json()}async createUser(){let e=this.generateRandomPassword(20),i=g.create(),n=await g.encrypt(i.privateKey,e),o=g.sign(JSON.stringify(n),i.privateKey).signature,r=await this.createUserToServer(n,o);if(r.code==0)return await this.setPassword(e),{keystore:n,account:i};throw new Error(r.error||r.msg)}async loadKeystore(){try{let e=await this.check(this.options);if(e.code)throw new Error(e.msg||e.error);if(e.isNewUser){let n=await this.createUser();this.account=n.account,this.keystore=n.keystore;return}let i=await this._getPassword();this.keystore=JSON.parse(e.keystore),this.account=await g.decrypt(this.keystore,i)}catch(e){console.log("loadKeystore error",e)}}request(e){return console.log("request",e),e.method=="eth_accounts"||e.method=="eth_requestAccounts"?new Promise((i,n)=>{try{if(this.account){i([this.account.address]);return}i([])}catch(s){n(s)}}):e.method=="eth_sendTransaction"?(e.method="eth_signTransaction",new Promise((i,n)=>{let s=e.params&&e.params.length&&e.params[0];s.gasLimit||(s.gasLimit=5e5),this.provider.request({method:"eth_chainId"}).then(o=>{console.log("eth_chainId ",o);let r=100199;o.result&&(r=parseInt(o.result,16)),s.chainId||(s.chainId=r),s.v=27+s.chainId*2+8,this.provider.request({method:"eth_getTransactionCount",params:[this.account.address]}).then(c=>{console.log("eth_getTransactionCount ",c),s.nonce||(s.nonce=c.result),console.log("before signTransaction param",s),g.signTransaction(new g.Transaction(s),this.account.privateKey).then(a=>{if(console.log("signTransaction ",a),a&&a.rawTransaction&&a.rawTransaction.length){const p={method:"eth_sendRawTransaction",params:[a.rawTransaction],id:this._nextId++,jsonrpc:"2.0"};this.provider.request(p).then(u=>{console.log("eth_sendRawTransaction ",u),i(u)}).catch(u=>{console.log("eth_sendRawTransaction error",u),n(u)})}else n(new Error("signTransaction error"))}).catch(a=>{console.log("signTransaction error",a),n(a)})}).catch(c=>{console.log("eth_getTransactionCount error",c),n(c)})}).catch(o=>{console.log("eth_chainId error",o),n(o)})})):this.provider.request(e)}async send(e,i){console.log("send",e,i);const n={method:e,params:i,id:this._nextId++,jsonrpc:"2.0"};return this.request(n)}}async function _(t=new l){console.log("detectEthereumProvider in");let e=!1;return await new Promise(async(n,s)=>{if(window.ethereum){if(t.force_aon&&!window.ethereum.isAON){let r=await o(t);n(r)}n(window.ethereum)}else{let r=await o(t);n(r)}async function o(r){if(console.log("createProvider in"),e)return;e=!0;const c=new x(r);return await c.loadKeystore(),window.ethereum=c,console.log("createProvider instance",c),c}})}class A{constructor(e=new l){this.options=e}async login(){return(await _(this.options)).request({method:"eth_accounts"})}}const B=1,U=2,L={1:"/api",2:"/jwt"};class N{constructor(e){if(!(e&&e.auth&&e.auth.length))throw new Error("options.auth is not found");this.auth=e.auth,this.options=e,this.init()}init(){let e="/v1";this.options&&this.options.api_version&&this.options.api_version.length&&(e=this.options.api_version),this.auth_type=this.parseAuthType(this.auth),this.path=L[this.auth_type]+e}parseAuthType(e){const i=this.decodeBase64(e);return console.log("parseAuthType",i),i.indexOf("JWT")>-1?U:B}decodeBase64(e){return typeof window<"u"&&typeof window.atob=="function"?window.atob(e):Buffer.from(e,"base64").toString("utf-8")}async prediction(e,i){try{let n="https://api.aonet.ai";this.options&&this.options.host&&this.options.host.length&&(n=this.options.host);const s=n+this.path+e;let o={apikey:this.auth};if(this.auth_type==U&&(o={Authorization:"Bearer "+this.auth}),this.options&&this.options.headers)for(const a in this.options.headers)a!="apikey"&&a!="Authorization"&&(o[a]=this.options.headers[a]);const r=await fetch(s,{method:"POST",headers:o,body:JSON.stringify(i)});return r?await r.json():{task:{is_success:!1,task_error:"network error",exec_code:"5000"}}}catch(n){console.error("Error:",n)}}}return function(t,e){typeof define=="function"&&define.amd?define(["web3","web3-eth-accounts"],e):typeof module=="object"&&module.exports?module.exports=e(require("web3"),require("web3-eth-accounts")):t.aonweb=e(t.Web3,t.Web3EthAccounts)}(typeof self<"u"?self:void 0,function(t,e){return{Options:l,User:A,AI:N,detectEthereumProvider:_}}),d.AI=N,d.Options=l,d.User=A,d.detectEthereumProvider=_,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"}),d}({},Web3,Web3EthAccounts);
(function(p,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("web3"),require("web3-eth-accounts")):typeof define=="function"&&define.amd?define(["exports","web3","web3-eth-accounts"],w):(p=typeof globalThis<"u"?globalThis:p||self,w(p.aonweb={},p.Web3,p.Web3EthAccounts))})(this,function(p,w,g){"use strict";const T={TYPE_TG:1,TYPE_FP:2};let l=class{constructor({rpc_url:e="https://dev.rpc.aonet.ai",type:i=T.TYPE_FP,server:n="https://dev.rpc.aonet.ai",password:s="",storeage_url:o="",timeout:r=3e3,force_aon:c=!0}={}){if(this.rpc_url=e,this.type=i,this.server=n,this.password=s,this.storeage_url=o,this.timeout=r,this.force_aon=c,this.type==T.TYPE_FP&&this.storeage_url=="")throw new Error("storeage_url must be set when type = TYPE_FP")}static get LoginTypes(){return T}};var y;(function(t){t.NUMBER="NUMBER_NUMBER",t.HEX="NUMBER_HEX",t.STR="NUMBER_STR",t.BIGINT="NUMBER_BIGINT"})(y||(y={}));var f;(function(t){t.HEX="BYTES_HEX",t.UINT8ARRAY="BYTES_UINT8ARRAY"})(f||(f={})),y.BIGINT,f.HEX,y.HEX,f.HEX;var I;(function(t){t.EARLIEST="earliest",t.LATEST="latest",t.PENDING="pending",t.SAFE="safe",t.FINALIZED="finalized"})(I||(I={}));var b;(function(t){t.chainstart="chainstart",t.frontier="frontier",t.homestead="homestead",t.dao="dao",t.tangerineWhistle="tangerineWhistle",t.spuriousDragon="spuriousDragon",t.byzantium="byzantium",t.constantinople="constantinople",t.petersburg="petersburg",t.istanbul="istanbul",t.muirGlacier="muirGlacier",t.berlin="berlin",t.london="london",t.altair="altair",t.arrowGlacier="arrowGlacier",t.grayGlacier="grayGlacier",t.bellatrix="bellatrix",t.merge="merge",t.capella="capella",t.shanghai="shanghai"})(b||(b={}));var E=function(t,e,i,n){function s(o){return o instanceof i?o:new i(function(r){r(o)})}return new(i||(i=Promise))(function(o,r){function c(u){try{d(n.next(u))}catch(P){r(P)}}function a(u){try{d(n.throw(u))}catch(P){r(P)}}function d(u){u.done?o(u.value):s(u.value).then(c,a)}d((n=n.apply(t,e||[])).next())})};const S=Symbol.for("web3/base-provider");class _{static isWeb3Provider(e){return e instanceof _||!!(e&&e[S])}get[S](){return!0}send(e,i){this.request(e).then(n=>{i(null,n)}).catch(n=>{i(n)})}sendAsync(e){return E(this,void 0,void 0,function*(){return this.request(e)})}asEIP1193Provider(){const e=Object.create(this),i=e.request;return e.request=function(s){return E(this,void 0,void 0,function*(){return(yield i(s)).result})},e.asEIP1193Provider=void 0,e}}class q{constructor(e=new Options){try{this.options=e}catch(i){throw i}}async setItem(e,i,n){try{let s=localStorage.getItem("fingerprint"),o={key:e+"_"+s,value:i},r=localStorage.getItem("token");r=r.replace(/^\"|\"$/g,"");let c={Authorization:"Bearer "+r},a=this.options.storeage_url+"/kvapi/v1/storage/set";const u=await(await fetch(a,{method:"POST",headers:c,body:JSON.stringify(o)})).json();u&&u.success?n(null):n(new Error(JSON.stringify(u)||""))}catch(s){n(s)}}async getItem(e,i){try{let n=localStorage.getItem("token");n=n.replace(/^\"|\"$/g,"");let s={Authorization:"Bearer "+n},o=localStorage.getItem("fingerprint");e=e+"_"+o;let r=this.options.storeage_url+"/kvapi/v1/storage/get?key="+e;const a=await(await fetch(r,{method:"GET",headers:s})).json();a&&a.success?i(null,a.value):i(new Error(JSON.stringify(a)||""),null)}catch(n){i(n,null)}}}let m;const R=new Uint8Array(16);function x(){if(!m&&(m=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!m))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return m(R)}const h=[];for(let t=0;t<256;++t)h.push((t+256).toString(16).slice(1));function Y(t,e=0){return h[t[e+0]]+h[t[e+1]]+h[t[e+2]]+h[t[e+3]]+"-"+h[t[e+4]]+h[t[e+5]]+"-"+h[t[e+6]]+h[t[e+7]]+"-"+h[t[e+8]]+h[t[e+9]]+"-"+h[t[e+10]]+h[t[e+11]]+h[t[e+12]]+h[t[e+13]]+h[t[e+14]]+h[t[e+15]]}const A={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function G(t,e,i){if(A.randomUUID&&!e&&!t)return A.randomUUID();t=t||{};const n=t.random||(t.rng||x)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,Y(n)}class W extends _{constructor(e=new l){try{super(),this.options=e,this.isAON=!0,window.Telegram&&window.Telegram.WebApp&&window.Telegram.WebApp.initData&&(e.type=l.LoginTypes.TYPE_TG),e.type==l.LoginTypes.TYPE_TG?(this.webapp=window.Telegram.WebApp,this.storage=window.Telegram.WebApp.CloudStorage):e.type==l.LoginTypes.TYPE_FP&&(this.storage=new q(e)),this.keystore=null,this.account=null,this._nextId=0,this.provider=new w.Web3.providers.HttpProvider(e.rpc_url)}catch(i){throw i}}async _getPassword(){return await new Promise((i,n)=>{this.storage.getItem("aon_web_sdk_password",(s,o)=>{s&&n(s),i(o)})})}async check(e){try{let i={};if(e.type==l.LoginTypes.TYPE_TG)i={platform:"telegram",initData:this.webapp.initData};else if(e.type==l.LoginTypes.TYPE_FP){let r=localStorage.getItem("fingerprint");r||(r=await new Promise((c,a)=>{const d=G();c(d)}),localStorage.setItem("fingerprint",r)),i={platform:"fingerprint",visitorId:r}}let n=e.server+"/api/v1/user/check";const o=await(await fetch(n,{method:"POST",body:JSON.stringify(i)})).json();if(o.code==0&&o.data){const r=o.data.token;return r&&this.setAuth(r),o.data}return o}catch(i){throw i}}async setPassword(e){await new Promise((i,n)=>{this.storage.setItem("aon_web_sdk_password",e,s=>{s&&n(s),i()})})}generateRandomPassword(e){const i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+{}|:<>?-=[];',./";let n="";for(let s=0;s<e;s++){const o=Math.floor(Math.random()*i.length);n+=i[o]}return n}async getAuth(){return this.options.type==l.LoginTypes.TYPE_TG?await new Promise((i,n)=>{this.storage.getItem("token",(s,o)=>{s&&n(s),i(o)})}):localStorage.getItem("token")}async setAuth(e){this.options.type==l.LoginTypes.TYPE_TG?await new Promise((i,n)=>{this.storage.setItem("token",JSON.stringify(e),s=>{s&&n(s),i()})}):localStorage.setItem("token",e)}async createUserToServer(e,i){let n={keystore:JSON.stringify(e),signature:i},s=await this.getAuth();s=s.replace(/^\"|\"$/g,"");let o={Authorization:"Bearer "+s},r=this.options.server+"/api/v1/user/create";return await(await fetch(r,{method:"POST",headers:o,body:JSON.stringify(n)})).json()}async createUser(){let e=this.generateRandomPassword(20),i=g.create(),n=await g.encrypt(i.privateKey,e),o=g.sign(JSON.stringify(n),i.privateKey).signature,r=await this.createUserToServer(n,o);if(r.code==0)return await this.setPassword(e),{keystore:n,account:i};throw new Error(r.error||r.msg)}async loadKeystore(){try{let e=await this.check(this.options);if(e.code)throw new Error(e.msg||e.error);if(e.isNewUser){let n=await this.createUser();this.account=n.account,this.keystore=n.keystore;return}let i=await this._getPassword();this.keystore=JSON.parse(e.keystore),this.account=await g.decrypt(this.keystore,i)}catch(e){console.log("loadKeystore error",e)}}request(e){return console.log("request",e),e.method=="eth_accounts"||e.method=="eth_requestAccounts"?new Promise((i,n)=>{try{if(this.account){i([this.account.address]);return}i([])}catch(s){n(s)}}):e.method=="eth_sendTransaction"?(e.method="eth_signTransaction",new Promise((i,n)=>{let s=e.params&&e.params.length&&e.params[0];s.gasLimit||(s.gasLimit=5e5),this.provider.request({method:"eth_chainId"}).then(o=>{console.log("eth_chainId ",o);let r=100199;o.result&&(r=parseInt(o.result,16)),s.chainId||(s.chainId=r),s.v=27+s.chainId*2+8,this.provider.request({method:"eth_getTransactionCount",params:[this.account.address]}).then(c=>{console.log("eth_getTransactionCount ",c),s.nonce||(s.nonce=c.result),console.log("before signTransaction param",s),g.signTransaction(new g.Transaction(s),this.account.privateKey).then(a=>{if(console.log("signTransaction ",a),a&&a.rawTransaction&&a.rawTransaction.length){const d={method:"eth_sendRawTransaction",params:[a.rawTransaction],id:this._nextId++,jsonrpc:"2.0"};this.provider.request(d).then(u=>{console.log("eth_sendRawTransaction ",u),i(u)}).catch(u=>{console.log("eth_sendRawTransaction error",u),n(u)})}else n(new Error("signTransaction error"))}).catch(a=>{console.log("signTransaction error",a),n(a)})}).catch(c=>{console.log("eth_getTransactionCount error",c),n(c)})}).catch(o=>{console.log("eth_chainId error",o),n(o)})})):this.provider.request(e)}async send(e,i){console.log("send",e,i);const n={method:e,params:i,id:this._nextId++,jsonrpc:"2.0"};return this.request(n)}}async function v(t=new l){console.log("detectEthereumProvider in");let e=!1;return await new Promise(async(n,s)=>{if(window.ethereum){if(t.force_aon&&!window.ethereum.isAON){let r=await o(t);n(r)}n(window.ethereum)}else{let r=await o(t);n(r)}async function o(r){if(console.log("createProvider in"),e)return;e=!0;const c=new W(r);return await c.loadKeystore(),window.ethereum=c,console.log("createProvider instance",c),c}})}class U{constructor(e=new l){this.options=e}async login(){return(await v(this.options)).request({method:"eth_accounts"})}}const B=1,N=2,L={1:"/api",2:"/jwt"};class D{constructor(e){if(!(e&&e.auth&&e.auth.length))throw new Error("options.auth is not found");this.auth=e.auth,this.options=e,this.init()}init(){let e="/v1";this.options&&this.options.api_version&&this.options.api_version.length&&(e=this.options.api_version),this.auth_type=this.parseAuthType(this.auth),this.path=L[this.auth_type]+e}parseAuthType(e){const i=this.decodeBase64(e);return console.log("parseAuthType",i),i.indexOf("JWT")>-1?N:B}decodeBase64(e){return typeof window<"u"&&typeof window.atob=="function"?window.atob(e):Buffer.from(e,"base64").toString("utf-8")}async prediction(e,i){try{let n="https://api.aonet.ai";this.options&&this.options.host&&this.options.host.length&&(n=this.options.host);const s=n+this.path+e;let o={apikey:this.auth};if(this.auth_type==N&&(o={Authorization:"Bearer "+this.auth}),this.options&&this.options.headers)for(const a in this.options.headers)a!="apikey"&&a!="Authorization"&&(o[a]=this.options.headers[a]);const r=await fetch(s,{method:"POST",headers:o,body:JSON.stringify(i)});return r?await r.json():{task:{is_success:!1,task_error:"network error",exec_code:"5000"}}}catch(n){console.error("Error:",n)}}}(function(t,e){typeof define=="function"&&define.amd?define(["web3","web3-eth-accounts"],e):typeof module=="object"&&module.exports?module.exports=e(require("web3"),require("web3-eth-accounts")):t.aonweb=e(t.Web3,t.Web3EthAccounts)})(typeof self<"u"?self:void 0,function(t,e){return{Options:l,User:U,AI:D,detectEthereumProvider:v}}),p.AI=D,p.Options=l,p.User=U,p.detectEthereumProvider=v,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
import './assets/main.css'
import { createApp } from 'vue'
import { Uploader } from 'vant';
import App from './App.vue'
import router from './router'
const app = createApp(App)
app.use(router)
app.use(Uploader)
app.mount('#app')
import { createRouter, createWebHistory } from 'vue-router'
import Index from '../views/Index.vue'
import User from '../views/User.vue'
import Created from '../views/Created.vue'
import Complete from '../views/Complete.vue'
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{
path: '/',
name: 'home',
component: Index
},
{
path: '/user',
name: 'user',
component: User
},
{
path: '/created',
name: 'created',
component: Created
},
{
path: '/complete',
name: 'complete',
component: Complete
}
]
})
export default router
// shims-vue.d.ts
declare module '*.vue' {
import { DefineComponent } from 'vue';
const component: DefineComponent<{}, {}, any>;
export default component;
}
declare module 'fullpage.js';
<template>
<Header></Header>
<div class="user">
<div class="container complete">
<div>
<text class="back" @click="goBack">{{ '<' }}BACK</text>
</div>
<img class="completeIcon" src="../assets/images/complete.png" mode=""></img>
<text class="p1">
Complete the task to obtain AON Points
</text>
<text class="p2">
Your current points are insufficient. Please complete the task to obtain more AON Points.
</text>
<button>Share</button>
</div>
</div>
</template>
<script setup>
import {
ref,
} from 'vue';
import { useRoute,useRouter } from 'vue-router'
import Header from '../components/Header.vue';
const router = useRouter()
const goBack = () => {
router.back();
}
</script>
<style scoped>
.complete {
padding-top: 4.27vw;
display: flex;
flex-direction: column;
justify-content: center;
}
.back {
font-family: Roboto-Bold;
font-weight: bold;
font-size: 3.2vw;
color: #000000;
text-align: left;
font-style: normal;
text-decoration-line: underline;
text-transform: none;
}
.completeIcon {
width: 67.2vw;
height: 49.6vw;
margin: 0 auto;
margin-top: 16.53vw;
margin-bottom: 18.13vw;
}
.p1 {
font-family: Roboto-Black;
font-weight: 900;
font-size: 6.4vw;
color: #000000;
line-height: 9.07vw;
text-align: left;
font-style: normal;
text-transform: none;
margin-bottom: 4.27vw;
}
.p2 {
font-family: Roboto-Regular;
font-weight: 400;
font-size: 3.2vw;
color: #000000;
line-height: 4.8vw;
text-align: left;
font-style: normal;
text-transform: none;
}
button {
width: 65.07vw;
height: 9.07vw;
line-height: 9.07vw;
background: #2F54EB;
box-shadow: 1.07vw 1.07vw 2.13vw .13vw rgba(47, 84, 235, 0.32);
border-radius: 1.07vw;
font-family: Roboto-Black;
font-weight: 900;
font-size: 3.73vw;
color: #FFFFFF;
text-align: center;
font-style: normal;
text-transform: none;
margin: 0 auto;
margin-top: 14.4vw;
border: none;
}
</style>
<template>
<div class="">
<Header></Header>
<div class="container created">
<div class="resCon">
<img class="res_img" :src="imageUrl" mode=""></img>
</div>
<div class="download">
<img src="../assets/icons/download.png" @click="downloadImage" mode=""></img>
</div>
<div class="bottom_btn">
<button class="createMore" @click="goToCreate">Generate More</button>
<button class="shareBtn">Share</button>
</div>
</div>
</div>
</template>
<script setup>
import {
ref,
onMounted
} from 'vue';
import { useRoute, useRouter } from 'vue-router'
import Header from '../components/Header.vue';
const router = useRouter()
const route = useRoute()
const imageUrl = ref('')
function goToCreate() {
router.push({
path: '/'
})
}
async function downloadImage() {
if (!imageUrl.value) return;
try {
// Fetch the image as a blob
const response = await fetch(imageUrl.value);
const blob = await response.blob();
// Create a link element and set the URL using the blob
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = 'downloaded-image.jpg'; // 设置下载的文件名
// Append the link to the body and click it to trigger the download
document.body.appendChild(link);
link.click();
// Clean up by removing the link element
document.body.removeChild(link);
} catch (error) {
console.error('Error downloading the image:', error);
}
}
onMounted(() => {
imageUrl.value = route.query.url;
})
</script>
<style scoped>
.created {
padding-top: 8.53vw;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.resCon{
display: flex;
justify-content: center;
align-items: center;
height: 116.27vw;
width: 100%;
}
.res_img {
width: 100%;
height: auto;
max-height: 116.27vw;
}
.download {
position: fixed;
bottom: 23.73vw;
left: 50%;
transform: translateX(-50%);
width: 10.67vw;
height: 10.67vw;
border-radius: 100%;
background: #F1F1F1;
display: flex;
justify-content: center;
align-items: center;
}
.download img {
height: 4.27vw;
width: 4.27vw;
}
button {
font-family: Roboto-Black;
font-weight: 900;
font-size: 3.73vw;
color: #FFFFFF;
text-align: center;
font-style: normal;
text-transform: none;
}
.createMore {
width: 50.67vw;
height: 9.07vw;
background: #000000;
box-shadow: 1.07vw 1.07vw 2.13vw .13vw rgba(0, 0, 0, 0.32);
border-radius: 1.07vw;
}
.shareBtn {
width: 32.27vw;
height: 9.07vw;
background: #2F54EB;
box-shadow: 1.07vw 1.07vw 2.13vw .13vw rgba(47, 84, 235, 0.32);
border-radius: 1.07vw;
}
</style>
<template>
<Header></Header>
<Loading :showLoading="showLoading" />
<div>
<!-- 页面内容 -->
<div class="container">
<img class="banner" src="../assets/images/banner.png" mode=""></img>
<div class="uni-form-item uni-column">
<div class="title">Upload your photos</div>
<div class="content">
<div class="upload upload-done" v-if="imgUrl">
<img class="upload-res" :src="imgUrl" mode=""></img>
<img class="deleteIcon" @click="deleteImg" src="../assets/icons/delete.png" mode=""></img>
</div>
<van-uploader v-else style="width: 100%" :max-size="maxSize" @oversize="onOversize"
:after-read="afterRead">
<div class="upload upload-before">
<img class="uploadIcon" src="../assets/icons/uploadImg.png" mode=""></img>
<text>limit 30MB per file</text>
</div>
</van-uploader>
</div>
</div>
<div class="uni-form-item uni-column">
<div class="title">Customize your clothing logo</div>
<div class="content">
<input v-model="logoText" name="input" placeholder="Please enter the logo text on your clothes" />
</div>
</div>
<div class="uni-form-item error-text" v-if="showError">
<div class="content">Please Upload your photos</div>
</div>
<div class="bottom_btn">
<div class="spendCount">
<img class="icon" src="../assets/icons/money.png" mode=""></img>
<text>-8</text>
</div>
<button class="submitBtn" @click="formSubmit">
<text>Generate img</text>
</button>
</div>
</div>
</div>
</template>
<script setup>
import { ref } from 'vue';
import { showToast } from 'vant';
import { useRouter } from 'vue-router'
import { AI } from '../lib/aonweb/aon-web.es'
import 'vant/lib/index.css';
import Header from '../components/Header.vue';
import Loading from '../components/Loading.vue';
const router = useRouter()
const showLoading = ref(false);
const showError = ref(false);
const logoText = ref('');
const imgUrl = ref('');
const submitImgUrl = ref('');
const maxSize = 30 * 1024 * 1024;
function goToComplete(url) {
const query = { url: url }
router.push({
path: '/created',
query
})
}
const onOversize = (file) => {
console.log(file);
showToast('文件大小不能超过 30MB');
};
function afterRead(file) {
const formData = new FormData();
formData.append('file', file.file);
console.log(formData, file.file)
// 调用上传接口
uploadFile(formData).then(res => {
console.log(res);
if (res.code == 200 && res.data && res.data.length) {
submitImgUrl.value = res.data
}
}).catch(err => {
showToast('image upload failed');
console.log(err);
});
imgUrl.value = URL.createObjectURL(file.file);
}
// 上传接口
const uploadFile = async (formData) => {
const response = await fetch('https://tmp-file.aigic.ai/api/v1/upload?expires=1800&type=image/png', {
method: 'POST',
body: formData
});
const data = await response.json();
console.log(data);
return data;
};
function deleteImg() {
if (imgUrl.value) {
const formData = new FormData();
formData.append('file', imgUrl.value);
// 删除文件
formData.delete('file');
imgUrl.value = null;
submitImgUrl.value = null
console.log('File deleted:', formData.get('file'));
} else {
console.log('No file to delete')
}
}
const formSubmit = async () => {
if (!logoText.value || !imgUrl.value || !submitImgUrl.value) {
showError.value = true
setTimeout(() => {
showError.value = false
}, 3000)
return
}
showLoading.value = true
try {
// AI 使用方法
const ai_options = {
//Please replace with your own API key or jwt token.
auth: "Rbhpcp0FKNrYNA1nZkrwrIbD0YSSRlVG",
// host: "http://localhost:8080"
}
const aonet = new AI(ai_options)
const data = {
input: {
"image": submitImgUrl.value,
"style": "3D",
"prompt": logoText.value,
"negative_prompt": "",
"prompt_strength": 4.5,
"denoising_strength": 1,
"instant_id_strength": 0.8
}
}
console.log("formSubmit data", data)
let response = await aonet.prediction("/predictions/ai/face-to-many", data)
console.log("test", response)
if (response.task.exec_code == 200 && response.task.is_success) {
showLoading.value = false
let url = response.output
if (Array.isArray(response.output)) {
url = response.output && response.output.length && response.output[0]
}
if (typeof url == 'object' || typeof url == 'Object') {
return
}
goToComplete(url)
} else {
showLoading.value = false
showToast('AI processing failed')
}
} catch (error) {
showLoading.value = false
showToast('AI processing failed')
}
}
</script>
<style scoped>
.banner {
width: 100%;
height: 27.73vw;
margin-top: 8.53vw;
margin-bottom: 8.53vw;
}
.uni-form-item .title {
font-family: Roboto-Bold;
font-weight: bold;
font-size: 3.73vw;
color: #000000;
text-align: left;
font-style: normal;
text-transform: none;
margin-bottom: 2.13vw;
}
.uni-form-item {
margin-bottom: 8.53vw;
}
.uni-form-item .content {
width: 100%;
height: 14.93vw;
background: #F1F1F1;
border-radius: 1.07vw;
display: flex;
align-items: center;
padding: 0 3.2vw;
box-sizing: border-box;
}
.error-text .content {
background-color: #F3A32B;
font-size: 3.2vw;
color: #fff;
}
.uni-form-item .content input {
width: 100%;
font-size: 3.2vw;
font-family: Roboto-Regular;
border: none;
outline: none;
background-color: #F1F1F1;
}
.upload {
width: 100%;
display: flex;
align-items: center;
}
.upload-before text {
color: #575757;
font-size: 3.2vw;
font-family: Roboto-Regular;
}
.upload-done {
justify-content: space-between;
}
.uploadIcon {
width: 6.4vw;
height: 6.4vw;
margin-right: 2.13vw;
}
.upload-res {
width: auto;
max-height: 8.53vw;
}
.deleteIcon {
height: 5.07vw;
width: 5.07vw;
}
.bottom_btn .spendCount {
width: 19.2vw;
height: 9.07vw;
background: #F1F1F1;
border-radius: 1.07vw;
display: flex;
justify-content: center;
align-items: center;
}
.bottom_btn .spendCount .icon {
height: 6.4vw;
width: 6.4vw;
margin-right: 1.07vw;
}
.bottom_btn .submitBtn {
width: 64.8vw;
height: 9.07vw;
background: #000000;
box-shadow: 1.07vw 1.07vw 2.13vw .13vw rgba(0, 0, 0, 0.32);
border-radius: 1.07vw;
display: flex;
justify-content: center;
align-items: center;
}
.bottom_btn .submitBtn text {
font-size: 3.73vw;
font-weight: bold;
background: linear-gradient(182deg, #2F54EB 0%, #FF26A8 100%);
-webkit-background-clip: text;
color: transparent;
background-clip: text;
}
</style>
<template>
<Header></Header>
<div class="user">
<div class="container">
<div class="ava-con">
<img class="ava" src="../assets/icons/user.png" mode=""></img>
<div class="ava-con-r">
<text class="userId">user-125482</text>
<text class="address">
{{ account }}
<img class="copy" src="../assets/icons/copy.png" @click="handleCopy" mode="" />
</text>
</div>
</div>
<img @click="goToComplete" class="person-banner" src="../assets/images/personBanner.png" mode=""></img>
<!-- <div class="myWork">
<text>My work</text>
<div class="waterfall">
<div class="waterfall-column" v-for="(column, index) in columns" :key="index">
<img v-for="item in column" :key="item.id" :src="item.src" class="waterfall-item" />
</div>
</div>
</div> -->
<div class="bottom_btn">
<button @click="goToCreate">
Go To Create
</button>
</div>
</div>
</div>
</template>
<script setup>
import {
ref,
onMounted
} from 'vue';
import { useRouter } from 'vue-router'
import { Options, User } from '../lib/aonweb/aon-web.es'
import { showToast } from 'vant';
import Header from '../components/Header.vue';
const router = useRouter()
const account = ref('')
const handleCopy = async () => {
try {
await navigator.clipboard.writeText(account.value);
showToast('复制成功');
} catch (err) {
showToast('复制失败');
}
};
function goToCreate() {
router.push({
path: '/'
})
}
function goToComplete() {
router.push({
path: '/complete'
})
}
// https://app.aonet.ai/api
// https://app.aonet.ai/kvapi
async function getAccount() {
const options = new Options({
type: Options.LoginTypes.TYPE_FP,
server: 'https://app.aonet.ai',
storeage_url: 'https://app.aonet.ai'
});
console.log(options)
//User 的使用方法
let user = new User(options)
let addr = await user.login()
console.log("getWeb3 account", addr)
account.value = addr[0]
// //detectEthereumProvider 的使用方法
// let ethereum = await detectEthereumProvider(options)
// if (ethereum) {
// // console.log(ethereum)
// const web3 = new Web3(ethereum);
// try {
// let account = await ethereum.request({ method: 'eth_requestAccounts' })
// console.log('getWeb3 account', account)
// account = account[0]
// return web3;
// } catch (error) {
// // User denied account access...
// return null;
// }
// }
// // AI 使用方法
// const ai_options = {
// //Please replace with your own API key or jwt token.
// auth: "$API_KEY"
// }
// const aonet = new AI(ai_options)
// let response = await aonet.prediction("/predictions/ai/face-to-many",
// {
// input: {
// "image": "https://aonet.ai/pbxt/KW7CdCusXMkkOs9bbCGYsInC8EUxlj3yBLxvfW9Fs9FFMZUL/MTk4MTczMTkzNzI1Mjg5NjYy.webp",
// "style": "3D",
// "prompt": "a zombie in a fire, burning flames behind him",
// "negative_prompt": "boring",
// "prompt_strength": 4.5,
// "denoising_strength": 1,
// "instant_id_strength": 0.8
// }
// })
// console.log("test", response)
}
onMounted(() => {
getAccount()
})
</script>
<style scoped>
.ava-con {
width: 100%;
margin-top: 8.53vw;
display: flex;
flex-direction: row;
box-sizing: border-box;
}
.ava-con .ava {
height: 22.93vw;
width: 22.93vw;
margin-right: 4.27vw;
}
.ava-con-r {
width: 60vw;
display: flex;
flex-wrap: wrap;
flex-direction: column;
}
.ava-con-r text {
word-wrap: break-word;
font-family: Roboto-Regular;
font-weight: 400;
font-size: 3.73vw;
color: #000000;
line-height: 5.6vw;
text-align: left;
font-style: normal;
text-transform: none;
}
.ava-con-r .userId {
font-weight: bold;
font-size: 4.27vw;
line-height: 4.27vw;
margin-bottom: 3.2vw;
margin-top: 3.73vw;
text-transform: uppercase;
}
.copy {
height: 3.2vw;
width: 3.2vw;
}
.ava-con-r text {
width: 100%;
}
.person-banner {
width: 100%;
height: 36.27vw;
margin: 6.4vw 0;
}
.myWork text {
font-family: Roboto-Bold;
font-weight: bold;
font-size: 3.73vw;
color: #000000;
text-align: left;
font-style: normal;
text-transform: none;
margin-bottom: 4.27vw;
}
button {
width: 100%;
height: 9.07vw;
background: #000000;
box-shadow: 1.07vw 1.07vw 2.13vw .13vw rgba(0, 0, 0, 0.32);
border-radius: 1.07vw;
font-family: Roboto-Black;
font-weight: 900;
font-size: 3.73vw;
color: #FFFFFF;
text-align: center;
font-style: normal;
text-transform: none;
}
</style>
{
"extends": "@vue/tsconfig/tsconfig.dom.json",
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
"exclude": ["src/**/__tests__/*"],
"compilerOptions": {
"composite": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
}
}
{
"files": [],
"references": [
{
"path": "./tsconfig.node.json"
},
{
"path": "./tsconfig.app.json"
}
],
"compilerOptions": {
"allowJs": true,
"esModuleInterop": true,
}
}
{
"extends": "@tsconfig/node20/tsconfig.json",
"include": [
"vite.config.*",
"vitest.config.*",
"cypress.config.*",
"nightwatch.conf.*",
"playwright.config.*"
],
"compilerOptions": {
"composite": true,
"noEmit": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"module": "ESNext",
"moduleResolution": "Bundler",
"types": ["node"]
}
}
{
"rewrites": [
{
"source": "/(.*)",
"destination": "/index.html"
}
]
}
\ No newline at end of file
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import VueDevTools from 'vite-plugin-vue-devtools'
import commonjs from 'vite-plugin-commonjs';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
commonjs(),
vue(),
vueJsx(),
VueDevTools(),
],
base: '/',
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
server: {
host: '0.0.0.0',
port: 8080,
proxy: {
'/api': {
target: 'https://api.aonet.ai/',
changeOrigin: true,
},
},
}
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment