增加jazz icon的显示
This commit is contained in:
parent
6755744114
commit
3ea26dfbd7
@ -20,21 +20,24 @@
|
||||
"__id__": 2
|
||||
},
|
||||
{
|
||||
"__id__": 5
|
||||
"__id__": 7
|
||||
},
|
||||
{
|
||||
"__id__": 8
|
||||
"__id__": 10
|
||||
},
|
||||
{
|
||||
"__id__": 13
|
||||
}
|
||||
],
|
||||
"_active": true,
|
||||
"_level": 1,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 11
|
||||
"__id__": 16
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 12
|
||||
"__id__": 17
|
||||
},
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
@ -80,6 +83,139 @@
|
||||
"groupIndex": 0,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "New Node",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 1
|
||||
},
|
||||
"_children": [],
|
||||
"_active": true,
|
||||
"_level": 2,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 3
|
||||
},
|
||||
{
|
||||
"__id__": 4
|
||||
},
|
||||
{
|
||||
"__id__": 5
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 6
|
||||
},
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 100,
|
||||
"height": 100
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_position": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": -50,
|
||||
"y": -40,
|
||||
"z": 0
|
||||
},
|
||||
"_scale": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 1,
|
||||
"y": 1,
|
||||
"z": 1
|
||||
},
|
||||
"_rotationX": 0,
|
||||
"_rotationY": 0,
|
||||
"_quat": {
|
||||
"__type__": "cc.Quat",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"groupIndex": 0,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Graphics",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_enabled": true,
|
||||
"_lineWidth": 1,
|
||||
"_strokeColor": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 0,
|
||||
"g": 0,
|
||||
"b": 0,
|
||||
"a": 255
|
||||
},
|
||||
"_lineJoin": 2,
|
||||
"_lineCap": 0,
|
||||
"_fillColor": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_miterLimit": 10,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "c5608gXK6JJrLX5LYUMj20m",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_enabled": true,
|
||||
"ctx": {
|
||||
"__id__": 3
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "410bfGzqWJAR6EoTsDWcNya",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_enabled": true,
|
||||
"ctx": {
|
||||
"__id__": 3
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.PrefabInfo",
|
||||
"root": {
|
||||
"__id__": 1
|
||||
},
|
||||
"asset": {
|
||||
"__uuid__": "259e752f-837f-4d16-b21f-3c886e3a7a7e"
|
||||
},
|
||||
"fileId": "4b6UFHZ85KypoEGwVNt7lc",
|
||||
"sync": false
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "New Sprite",
|
||||
@ -92,11 +228,11 @@
|
||||
"_level": 5,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 3
|
||||
"__id__": 8
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 4
|
||||
"__id__": 9
|
||||
},
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
@ -147,7 +283,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 2
|
||||
"__id__": 7
|
||||
},
|
||||
"_enabled": true,
|
||||
"_srcBlendFactor": 770,
|
||||
@ -191,11 +327,11 @@
|
||||
"_level": 2,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 6
|
||||
"__id__": 11
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 7
|
||||
"__id__": 12
|
||||
},
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
@ -246,7 +382,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 5
|
||||
"__id__": 10
|
||||
},
|
||||
"_enabled": true,
|
||||
"_srcBlendFactor": 770,
|
||||
@ -292,11 +428,11 @@
|
||||
"_level": 5,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 9
|
||||
"__id__": 14
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 10
|
||||
"__id__": 15
|
||||
},
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
@ -347,7 +483,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 8
|
||||
"__id__": 13
|
||||
},
|
||||
"_enabled": true,
|
||||
"_useOriginalSize": false,
|
||||
@ -387,10 +523,13 @@
|
||||
},
|
||||
"_enabled": true,
|
||||
"nftIDlabel": {
|
||||
"__id__": 9
|
||||
"__id__": 14
|
||||
},
|
||||
"icon": {
|
||||
"__id__": 3
|
||||
"__id__": 8
|
||||
},
|
||||
"iconNode": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
|
@ -23,27 +23,27 @@
|
||||
"__id__": 6
|
||||
},
|
||||
{
|
||||
"__id__": 10
|
||||
"__id__": 11
|
||||
},
|
||||
{
|
||||
"__id__": 13
|
||||
"__id__": 14
|
||||
},
|
||||
{
|
||||
"__id__": 16
|
||||
"__id__": 17
|
||||
}
|
||||
],
|
||||
"_active": true,
|
||||
"_level": 1,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 19
|
||||
"__id__": 20
|
||||
},
|
||||
{
|
||||
"__id__": 20
|
||||
"__id__": 21
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 21
|
||||
"__id__": 22
|
||||
},
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
@ -236,10 +236,13 @@
|
||||
},
|
||||
{
|
||||
"__id__": 8
|
||||
},
|
||||
{
|
||||
"__id__": 9
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 9
|
||||
"__id__": 10
|
||||
},
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
@ -326,6 +329,19 @@
|
||||
"_miterLimit": 10,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "410bfGzqWJAR6EoTsDWcNya",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 6
|
||||
},
|
||||
"_enabled": true,
|
||||
"ctx": {
|
||||
"__id__": 8
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.PrefabInfo",
|
||||
"root": {
|
||||
@ -349,11 +365,11 @@
|
||||
"_level": 2,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 11
|
||||
"__id__": 12
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 12
|
||||
"__id__": 13
|
||||
},
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
@ -404,7 +420,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 10
|
||||
"__id__": 11
|
||||
},
|
||||
"_enabled": true,
|
||||
"_srcBlendFactor": 770,
|
||||
@ -450,11 +466,11 @@
|
||||
"_level": 5,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 14
|
||||
"__id__": 15
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 15
|
||||
"__id__": 16
|
||||
},
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
@ -505,7 +521,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 13
|
||||
"__id__": 14
|
||||
},
|
||||
"_enabled": true,
|
||||
"_useOriginalSize": false,
|
||||
@ -548,11 +564,11 @@
|
||||
"_level": 5,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 17
|
||||
"__id__": 18
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 18
|
||||
"__id__": 19
|
||||
},
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
@ -603,7 +619,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 16
|
||||
"__id__": 17
|
||||
},
|
||||
"_enabled": true,
|
||||
"_useOriginalSize": false,
|
||||
@ -671,10 +687,10 @@
|
||||
},
|
||||
"_enabled": true,
|
||||
"symbolLabel": {
|
||||
"__id__": 14
|
||||
"__id__": 15
|
||||
},
|
||||
"countLabel": {
|
||||
"__id__": 17
|
||||
"__id__": 18
|
||||
},
|
||||
"icon": {
|
||||
"__id__": 7
|
||||
|
@ -24,7 +24,6 @@ declare global {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export interface IChainData {
|
||||
name: string,
|
||||
type: string,
|
||||
@ -46,6 +45,7 @@ export default class JCWallet {
|
||||
public mainHandlers = createWalletEvents()
|
||||
private dataManage = new DataManage()
|
||||
public data: IAccount[] = []
|
||||
public iconType = 'jazz'
|
||||
|
||||
constructor() {
|
||||
// this.web3 = new Web3('https://rpc-mainnet.kcc.network')
|
||||
|
211
assets/comp/wallet/scripts/lib/mersenne-twister.ts
Normal file
211
assets/comp/wallet/scripts/lib/mersenne-twister.ts
Normal file
@ -0,0 +1,211 @@
|
||||
/*
|
||||
https://github.com/banksean wrapped Makoto Matsumoto and Takuji Nishimura's code in a namespace
|
||||
so it's better encapsulated. Now you can have multiple random number generators
|
||||
and they won't stomp all over eachother's state.
|
||||
|
||||
If you want to use this as a substitute for Math.random(), use the random()
|
||||
method like so:
|
||||
|
||||
var m = new MersenneTwister();
|
||||
var randomNumber = m.random();
|
||||
|
||||
You can also call the other genrand_{foo}() methods on the instance.
|
||||
|
||||
If you want to use a specific seed in order to get a repeatable random
|
||||
sequence, pass an integer into the constructor:
|
||||
|
||||
var m = new MersenneTwister(123);
|
||||
|
||||
and that will always produce the same random sequence.
|
||||
|
||||
Sean McCullough (banksean@gmail.com)
|
||||
*/
|
||||
|
||||
/*
|
||||
A C-program for MT19937, with initialization improved 2002/1/26.
|
||||
Coded by Takuji Nishimura and Makoto Matsumoto.
|
||||
|
||||
Before using, initialize the state by using init_seed(seed)
|
||||
or init_by_array(init_key, key_length).
|
||||
|
||||
Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. The names of its contributors may not be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
Any feedback is very welcome.
|
||||
http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
|
||||
email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)
|
||||
*/
|
||||
|
||||
export default class MersenneTwister {
|
||||
N = 624;
|
||||
M = 397;
|
||||
MATRIX_A = 0x9908b0df; /* constant vector a */
|
||||
UPPER_MASK = 0x80000000; /* most significant w-r bits */
|
||||
LOWER_MASK = 0x7fffffff; /* least significant r bits */
|
||||
|
||||
mt = new Array(this.N); /* the array for the state vector */
|
||||
mti=this.N+1; /* mti==N+1 means mt[N] is not initialized */
|
||||
|
||||
constructor(seed) {
|
||||
if (seed == undefined) {
|
||||
seed = new Date().getTime();
|
||||
}
|
||||
/* Period parameters */
|
||||
if (seed.constructor == Array) {
|
||||
this.init_by_array(seed, seed.length);
|
||||
}
|
||||
else {
|
||||
this.init_seed(seed);
|
||||
}
|
||||
}
|
||||
|
||||
/* initializes mt[N] with a seed */
|
||||
/* origin name init_genrand */
|
||||
init_seed(s1: number) {
|
||||
this.mt[0] = s1 >>> 0;
|
||||
for (this.mti=1; this.mti<this.N; this.mti++) {
|
||||
var s = this.mt[this.mti-1] ^ (this.mt[this.mti-1] >>> 30);
|
||||
this.mt[this.mti] = (((((s & 0xffff0000) >>> 16) * 1812433253) << 16) + (s & 0x0000ffff) * 1812433253)
|
||||
+ this.mti;
|
||||
/* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
|
||||
/* In the previous versions, MSBs of the seed affect */
|
||||
/* only MSBs of the array mt[]. */
|
||||
/* 2002/01/09 modified by Makoto Matsumoto */
|
||||
this.mt[this.mti] >>>= 0;
|
||||
/* for >32 bit machines */
|
||||
}
|
||||
}
|
||||
|
||||
/* initialize by an array with array-length */
|
||||
/* init_key is the array for initializing keys */
|
||||
/* key_length is its length */
|
||||
/* slight change for C++, 2004/2/26 */
|
||||
init_by_array(init_key, key_length) {
|
||||
var i, j, k;
|
||||
this.init_seed(19650218);
|
||||
i=1; j=0;
|
||||
k = (this.N>key_length ? this.N : key_length);
|
||||
for (; k; k--) {
|
||||
var s = this.mt[i-1] ^ (this.mt[i-1] >>> 30)
|
||||
this.mt[i] = (this.mt[i] ^ (((((s & 0xffff0000) >>> 16) * 1664525) << 16) + ((s & 0x0000ffff) * 1664525)))
|
||||
+ init_key[j] + j; /* non linear */
|
||||
this.mt[i] >>>= 0; /* for WORDSIZE > 32 machines */
|
||||
i++; j++;
|
||||
if (i>=this.N) { this.mt[0] = this.mt[this.N-1]; i=1; }
|
||||
if (j>=key_length) j=0;
|
||||
}
|
||||
for (k=this.N-1; k; k--) {
|
||||
var s = this.mt[i-1] ^ (this.mt[i-1] >>> 30);
|
||||
this.mt[i] = (this.mt[i] ^ (((((s & 0xffff0000) >>> 16) * 1566083941) << 16) + (s & 0x0000ffff) * 1566083941))
|
||||
- i; /* non linear */
|
||||
this.mt[i] >>>= 0; /* for WORDSIZE > 32 machines */
|
||||
i++;
|
||||
if (i>=this.N) { this.mt[0] = this.mt[this.N-1]; i=1; }
|
||||
}
|
||||
|
||||
this.mt[0] = 0x80000000; /* MSB is 1; assuring non-zero initial array */
|
||||
}
|
||||
|
||||
/* generates a random number on [0,0xffffffff]-interval */
|
||||
/* origin name genrand_int32 */
|
||||
random_int() {
|
||||
var y;
|
||||
var mag01 = new Array(0x0, this.MATRIX_A);
|
||||
/* mag01[x] = x * MATRIX_A for x=0,1 */
|
||||
|
||||
if (this.mti >= this.N) { /* generate N words at one time */
|
||||
var kk;
|
||||
|
||||
if (this.mti == this.N+1) /* if init_seed() has not been called, */
|
||||
this.init_seed(5489); /* a default initial seed is used */
|
||||
|
||||
for (kk=0;kk<this.N-this.M;kk++) {
|
||||
y = (this.mt[kk]&this.UPPER_MASK)|(this.mt[kk+1]&this.LOWER_MASK);
|
||||
this.mt[kk] = this.mt[kk+this.M] ^ (y >>> 1) ^ mag01[y & 0x1];
|
||||
}
|
||||
for (;kk<this.N-1;kk++) {
|
||||
y = (this.mt[kk]&this.UPPER_MASK)|(this.mt[kk+1]&this.LOWER_MASK);
|
||||
this.mt[kk] = this.mt[kk+(this.M-this.N)] ^ (y >>> 1) ^ mag01[y & 0x1];
|
||||
}
|
||||
y = (this.mt[this.N-1]&this.UPPER_MASK)|(this.mt[0]&this.LOWER_MASK);
|
||||
this.mt[this.N-1] = this.mt[this.M-1] ^ (y >>> 1) ^ mag01[y & 0x1];
|
||||
|
||||
this.mti = 0;
|
||||
}
|
||||
|
||||
y = this.mt[this.mti++];
|
||||
|
||||
/* Tempering */
|
||||
y ^= (y >>> 11);
|
||||
y ^= (y << 7) & 0x9d2c5680;
|
||||
y ^= (y << 15) & 0xefc60000;
|
||||
y ^= (y >>> 18);
|
||||
|
||||
return y >>> 0;
|
||||
}
|
||||
|
||||
/* generates a random number on [0,0x7fffffff]-interval */
|
||||
/* origin name genrand_int31 */
|
||||
random_int31() {
|
||||
return (this.random_int()>>>1);
|
||||
}
|
||||
|
||||
/* generates a random number on [0,1]-real-interval */
|
||||
/* origin name genrand_real1 */
|
||||
random_incl() {
|
||||
return this.random_int()*(1.0/4294967295.0);
|
||||
/* divided by 2^32-1 */
|
||||
}
|
||||
|
||||
/* generates a random number on [0,1)-real-interval */
|
||||
random() {
|
||||
return this.random_int()*(1.0/4294967296.0);
|
||||
/* divided by 2^32 */
|
||||
}
|
||||
|
||||
/* generates a random number on (0,1)-real-interval */
|
||||
/* origin name genrand_real3 */
|
||||
random_excl() {
|
||||
return (this.random_int() + 0.5)*(1.0/4294967296.0);
|
||||
/* divided by 2^32 */
|
||||
}
|
||||
|
||||
/* generates a random number on [0,1) with 53-bit resolution*/
|
||||
/* origin name genrand_res53 */
|
||||
random_long() {
|
||||
var a=this.random_int()>>>5, b=this.random_int()>>>6;
|
||||
return(a*67108864.0+b)*(1.0/9007199254740992.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
9
assets/comp/wallet/scripts/lib/mersenne-twister.ts.meta
Normal file
9
assets/comp/wallet/scripts/lib/mersenne-twister.ts.meta
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "c2bd61f3-5875-4349-ad0a-66bac07dbf97",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
@ -17,6 +17,10 @@ export default class OneNFT extends WalletBase {
|
||||
@property(cc.Sprite)
|
||||
icon: cc.Sprite = null;
|
||||
|
||||
// for default icon when no image load
|
||||
@property(cc.Node)
|
||||
iconNode: cc.Node = null;
|
||||
|
||||
data: INFT = null
|
||||
addressAccount: string = ''
|
||||
|
||||
@ -33,8 +37,14 @@ export default class OneNFT extends WalletBase {
|
||||
if (!this.wallet) {
|
||||
this.wallet = new JCWallet()
|
||||
}
|
||||
this.addressAccount = this.wallet.currentAccount().address
|
||||
this.data = data
|
||||
if (this.wallet.iconType === 'jazz') {
|
||||
this.iconNode.getComponent('JazzIcon').init(this.data.address)
|
||||
} else {
|
||||
this.iconNode.getComponent('HashIcon').init(this.data.address)
|
||||
}
|
||||
this.addressAccount = this.wallet.currentAccount().address
|
||||
|
||||
try {
|
||||
const tokenId = await this.wallet.erc721Standard.getCollectibleTokenId(
|
||||
this.data.address,
|
||||
|
@ -15,8 +15,8 @@ export default class OneToken extends WalletBase {
|
||||
@property(cc.Label)
|
||||
countLabel: cc.Label = null;
|
||||
|
||||
@property(HashIcon)
|
||||
icon: HashIcon = null;
|
||||
@property(cc.Node)
|
||||
icon: cc.Node = null;
|
||||
|
||||
data: IToken = null
|
||||
// LIFE-CYCLE CALLBACKS:
|
||||
@ -41,7 +41,11 @@ export default class OneToken extends WalletBase {
|
||||
let symbol = await this.wallet.erc20Standard.getTokenSymbol(this.data.address)
|
||||
this.data.symbol = symbol
|
||||
}
|
||||
this.icon.init(this.data.address)
|
||||
if (this.wallet.iconType === 'jazz') {
|
||||
this.icon.getComponent('JazzIcon').init(this.data.address)
|
||||
} else {
|
||||
this.icon.getComponent('HashIcon').init(this.data.address)
|
||||
}
|
||||
if (this.data.decimal === undefined && this.data.type !== ETH_TYPE) {
|
||||
// get from chain
|
||||
let decimal = await this.wallet.erc20Standard.getTokenDecimals(this.data.address)
|
||||
|
@ -4,6 +4,7 @@ import { Bind } from "../decorator/AutoUpdateUI";
|
||||
import JCWallet, { IChainData } from "../JCWallet";
|
||||
import { renderFromTokenMinimalUnit } from "../util/number.util";
|
||||
import HashIcon from "./comp/HashIcon";
|
||||
import JazzIcon from "./comp/JazzIcon";
|
||||
import WalletBase from "./WallerBase";
|
||||
|
||||
|
||||
@ -18,14 +19,12 @@ export default class WalletInfo extends WalletBase {
|
||||
@property(cc.Label)
|
||||
balanceLabel: cc.Label = null;
|
||||
|
||||
@property(HashIcon)
|
||||
avatar: HashIcon = null;
|
||||
@property(cc.Node)
|
||||
avatar: cc.Node = null;
|
||||
|
||||
accountId: string = '';
|
||||
|
||||
balance: string = ''
|
||||
@property(cc.Node)
|
||||
parentNode: cc.Node = null
|
||||
|
||||
// LIFE-CYCLE CALLBACKS:
|
||||
|
||||
@ -44,7 +43,12 @@ export default class WalletInfo extends WalletBase {
|
||||
super.updateUI()
|
||||
this.addressLabel.string = this.formatAddress()
|
||||
this.balanceLabel.string = this.formatMoney()
|
||||
this.avatar.init(this.accountId)
|
||||
if (this.wallet.iconType === 'jazz') {
|
||||
this.avatar.getComponent('JazzIcon').init(this.accountId)
|
||||
} else {
|
||||
this.avatar.getComponent('HashIcon').init(this.accountId)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
formatAddress() {
|
||||
|
95
assets/comp/wallet/scripts/ui/comp/JazzIcon.ts
Normal file
95
assets/comp/wallet/scripts/ui/comp/JazzIcon.ts
Normal file
@ -0,0 +1,95 @@
|
||||
import MersenneTwister from "../../lib/mersenne-twister";
|
||||
|
||||
const { ccclass, property } = cc._decorator;
|
||||
|
||||
@ccclass
|
||||
export default class JazzIcon extends cc.Component {
|
||||
private generator: MersenneTwister
|
||||
|
||||
@property(cc.Graphics)
|
||||
ctx: cc.Graphics = null;
|
||||
|
||||
private shapeCount = 4
|
||||
|
||||
private colors = []
|
||||
|
||||
init(address: string) {
|
||||
this.colors = [
|
||||
'#01888C', // teal
|
||||
'#FC7500', // bright orange
|
||||
'#034F5D', // dark teal
|
||||
'#F73F01', // orangered
|
||||
'#FC1960', // magenta
|
||||
'#C7144C', // raspberry
|
||||
'#F3C100', // goldenrod
|
||||
'#1598F2', // lightning blue
|
||||
'#2465E1', // sail blue
|
||||
'#F19E02', // gold
|
||||
]
|
||||
let seed = Date.now()
|
||||
if (address.startsWith("0x")) {
|
||||
seed = parseInt(address.slice(2, 10), 16);
|
||||
}
|
||||
let diameter: number = this.node.width
|
||||
this.generator = new MersenneTwister(seed);
|
||||
// let remainingColors = this.hueShift(this.colors.slice())
|
||||
this.generator.random()
|
||||
let remainingColors = this.colors.slice()
|
||||
|
||||
this.ctx.clear()
|
||||
this.ctx.fillColor = this.genColor(this.colors)
|
||||
this.ctx.fillRect(0, 0 , diameter, diameter)
|
||||
|
||||
for(var i = 0; i < this.shapeCount - 1; i++) {
|
||||
this.genShape(remainingColors, diameter, i, this.shapeCount - 1)
|
||||
}
|
||||
}
|
||||
|
||||
genColor(colors: string[]) {
|
||||
let rand = this.generator.random()
|
||||
var idx = Math.floor(colors.length * this.generator.random())
|
||||
var color = colors.splice(idx,1)[0]
|
||||
return new cc.Color().fromHEX(color)
|
||||
}
|
||||
|
||||
hueShift(colors: string[]) {
|
||||
this.generator.random()
|
||||
return colors
|
||||
}
|
||||
genShape(remainingColors: string[], diameter: number, i: number, total: number) {
|
||||
let firstRot = this.generator.random()
|
||||
let angle = Math.PI * 2 * firstRot
|
||||
let velocity = diameter / total * this.generator.random() + (i * diameter / total)
|
||||
let tx = (Math.cos(angle) * velocity)
|
||||
let ty = (Math.sin(angle) * velocity)
|
||||
let c1 = cc.v2(diameter / 2, diameter / 2)
|
||||
let c2 = cc.v2(tx, ty)
|
||||
|
||||
let secondRot = this.generator.random()
|
||||
let rot = (firstRot * 360) + secondRot * 180
|
||||
let angle2 = Math.PI * 2 * rot
|
||||
let p0 = this.moveAndRotate(cc.v2(0, 0), c1, c2, angle2, diameter)
|
||||
let p1 = this.moveAndRotate(cc.v2(0, diameter), c1, c2, angle2, diameter)
|
||||
let p2 = this.moveAndRotate(cc.v2(diameter, diameter), c1, c2, angle2, diameter)
|
||||
let p3 = this.moveAndRotate(cc.v2(diameter, 0), c1, c2, angle2, diameter)
|
||||
this.ctx.moveTo(p0.x, p0.y)
|
||||
this.ctx.lineTo(p1.x, p1.y)
|
||||
this.ctx.lineTo(p2.x, p2.y)
|
||||
this.ctx.lineTo(p3.x, p3.y)
|
||||
let fill = this.genColor(remainingColors)
|
||||
this.ctx.fillColor = fill
|
||||
this.ctx.fill()
|
||||
// this.ctx.stroke()
|
||||
}
|
||||
|
||||
moveAndRotate(p1: cc.Vec2, c1: cc.Vec2, c2: cc.Vec2, radians: number, diameter: number) {
|
||||
let x1 = c2.x - c1.x
|
||||
let y1 = c2.y - c1.y
|
||||
let tmpV2 = cc.v2(x1, y1)
|
||||
let p2 = p1.add(tmpV2).sub(c2)
|
||||
let r = p2.rotate(radians).add(c2)
|
||||
let x = Math.min(Math.max(0, r.x), diameter)
|
||||
let y = Math.min(Math.max(0, r.y), diameter)
|
||||
return cc.v2(x, y)
|
||||
}
|
||||
}
|
9
assets/comp/wallet/scripts/ui/comp/JazzIcon.ts.meta
Normal file
9
assets/comp/wallet/scripts/ui/comp/JazzIcon.ts.meta
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "410bf1b3-a962-4047-a128-4ec0d670dc9a",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
@ -17,7 +17,7 @@
|
||||
"__id__": 2
|
||||
},
|
||||
{
|
||||
"__id__": 187
|
||||
"__id__": 188
|
||||
}
|
||||
],
|
||||
"_active": false,
|
||||
@ -86,14 +86,14 @@
|
||||
"_active": true,
|
||||
"_level": 1,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 184
|
||||
},
|
||||
{
|
||||
"__id__": 185
|
||||
},
|
||||
{
|
||||
"__id__": 188
|
||||
"__id__": 186
|
||||
},
|
||||
{
|
||||
"__id__": 189
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
@ -4650,14 +4650,14 @@
|
||||
"_active": true,
|
||||
"_level": 1,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 181
|
||||
},
|
||||
{
|
||||
"__id__": 182
|
||||
},
|
||||
{
|
||||
"__id__": 183
|
||||
},
|
||||
{
|
||||
"__id__": 184
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
@ -6318,44 +6318,44 @@
|
||||
"__id__": 146
|
||||
},
|
||||
{
|
||||
"__id__": 149
|
||||
"__id__": 150
|
||||
},
|
||||
{
|
||||
"__id__": 151
|
||||
"__id__": 152
|
||||
},
|
||||
{
|
||||
"__id__": 153
|
||||
"__id__": 154
|
||||
},
|
||||
{
|
||||
"__id__": 161
|
||||
"__id__": 162
|
||||
},
|
||||
{
|
||||
"__id__": 167
|
||||
"__id__": 168
|
||||
},
|
||||
{
|
||||
"__id__": 169
|
||||
"__id__": 170
|
||||
},
|
||||
{
|
||||
"__id__": 171
|
||||
"__id__": 172
|
||||
},
|
||||
{
|
||||
"__id__": 173
|
||||
"__id__": 174
|
||||
},
|
||||
{
|
||||
"__id__": 175
|
||||
"__id__": 176
|
||||
},
|
||||
{
|
||||
"__id__": 177
|
||||
"__id__": 178
|
||||
}
|
||||
],
|
||||
"_active": true,
|
||||
"_level": 2,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 179
|
||||
"__id__": 180
|
||||
},
|
||||
{
|
||||
"__id__": 180
|
||||
"__id__": 181
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
@ -6419,6 +6419,9 @@
|
||||
},
|
||||
{
|
||||
"__id__": 148
|
||||
},
|
||||
{
|
||||
"__id__": 149
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
@ -6507,6 +6510,19 @@
|
||||
},
|
||||
"_id": "93to1VnftD2LgtNEbvXRbk"
|
||||
},
|
||||
{
|
||||
"__type__": "410bfGzqWJAR6EoTsDWcNya",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 146
|
||||
},
|
||||
"_enabled": true,
|
||||
"ctx": {
|
||||
"__id__": 147
|
||||
},
|
||||
"_id": "2alniidNZNjrb472fLhz4h"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "New Sprite",
|
||||
@ -6519,7 +6535,7 @@
|
||||
"_level": 3,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 150
|
||||
"__id__": 151
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
@ -6572,7 +6588,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 149
|
||||
"__id__": 150
|
||||
},
|
||||
"_enabled": true,
|
||||
"_srcBlendFactor": 770,
|
||||
@ -6607,7 +6623,7 @@
|
||||
"_level": 3,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 152
|
||||
"__id__": 153
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
@ -6660,7 +6676,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 151
|
||||
"__id__": 152
|
||||
},
|
||||
"_enabled": true,
|
||||
"_srcBlendFactor": 770,
|
||||
@ -6692,20 +6708,20 @@
|
||||
},
|
||||
"_children": [
|
||||
{
|
||||
"__id__": 154
|
||||
"__id__": 155
|
||||
},
|
||||
{
|
||||
"__id__": 156
|
||||
"__id__": 157
|
||||
}
|
||||
],
|
||||
"_active": true,
|
||||
"_level": 3,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 158
|
||||
"__id__": 159
|
||||
},
|
||||
{
|
||||
"__id__": 159
|
||||
"__id__": 160
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
@ -6758,14 +6774,14 @@
|
||||
"_name": "btn-receive",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 153
|
||||
"__id__": 154
|
||||
},
|
||||
"_children": [],
|
||||
"_active": true,
|
||||
"_level": 4,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 155
|
||||
"__id__": 156
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
@ -6818,7 +6834,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 154
|
||||
"__id__": 155
|
||||
},
|
||||
"_enabled": true,
|
||||
"_srcBlendFactor": 770,
|
||||
@ -6846,14 +6862,14 @@
|
||||
"_name": "label",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 153
|
||||
"__id__": 154
|
||||
},
|
||||
"_children": [],
|
||||
"_active": true,
|
||||
"_level": 4,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 157
|
||||
"__id__": 158
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
@ -6906,7 +6922,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 156
|
||||
"__id__": 157
|
||||
},
|
||||
"_enabled": true,
|
||||
"_useOriginalSize": false,
|
||||
@ -6931,7 +6947,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 153
|
||||
"__id__": 154
|
||||
},
|
||||
"_enabled": true,
|
||||
"_srcBlendFactor": 770,
|
||||
@ -6959,14 +6975,14 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 153
|
||||
"__id__": 154
|
||||
},
|
||||
"_enabled": true,
|
||||
"duration": 0.1,
|
||||
"zoomScale": 1.2,
|
||||
"clickEvents": [
|
||||
{
|
||||
"__id__": 160
|
||||
"__id__": 161
|
||||
}
|
||||
],
|
||||
"_N$interactable": true,
|
||||
@ -7043,17 +7059,17 @@
|
||||
},
|
||||
"_children": [
|
||||
{
|
||||
"__id__": 162
|
||||
"__id__": 163
|
||||
},
|
||||
{
|
||||
"__id__": 164
|
||||
"__id__": 165
|
||||
}
|
||||
],
|
||||
"_active": true,
|
||||
"_level": 3,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 166
|
||||
"__id__": 167
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
@ -7106,14 +7122,14 @@
|
||||
"_name": "btn-send",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 161
|
||||
"__id__": 162
|
||||
},
|
||||
"_children": [],
|
||||
"_active": true,
|
||||
"_level": 4,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 163
|
||||
"__id__": 164
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
@ -7166,7 +7182,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 162
|
||||
"__id__": 163
|
||||
},
|
||||
"_enabled": true,
|
||||
"_srcBlendFactor": 770,
|
||||
@ -7194,14 +7210,14 @@
|
||||
"_name": "New Label",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 161
|
||||
"__id__": 162
|
||||
},
|
||||
"_children": [],
|
||||
"_active": true,
|
||||
"_level": 4,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 165
|
||||
"__id__": 166
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
@ -7254,7 +7270,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 164
|
||||
"__id__": 165
|
||||
},
|
||||
"_enabled": true,
|
||||
"_useOriginalSize": false,
|
||||
@ -7279,7 +7295,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 161
|
||||
"__id__": 162
|
||||
},
|
||||
"_enabled": true,
|
||||
"_srcBlendFactor": 770,
|
||||
@ -7314,7 +7330,7 @@
|
||||
"_level": 3,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 168
|
||||
"__id__": 169
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
@ -7367,7 +7383,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 167
|
||||
"__id__": 168
|
||||
},
|
||||
"_enabled": true,
|
||||
"_srcBlendFactor": 770,
|
||||
@ -7402,7 +7418,7 @@
|
||||
"_level": 3,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 170
|
||||
"__id__": 171
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
@ -7455,7 +7471,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 169
|
||||
"__id__": 170
|
||||
},
|
||||
"_enabled": true,
|
||||
"_useOriginalSize": false,
|
||||
@ -7487,7 +7503,7 @@
|
||||
"_level": 3,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 172
|
||||
"__id__": 173
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
@ -7540,7 +7556,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 171
|
||||
"__id__": 172
|
||||
},
|
||||
"_enabled": true,
|
||||
"_useOriginalSize": false,
|
||||
@ -7572,7 +7588,7 @@
|
||||
"_level": 3,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 174
|
||||
"__id__": 175
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
@ -7625,7 +7641,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 173
|
||||
"__id__": 174
|
||||
},
|
||||
"_enabled": true,
|
||||
"_useOriginalSize": false,
|
||||
@ -7657,7 +7673,7 @@
|
||||
"_level": 3,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 176
|
||||
"__id__": 177
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
@ -7710,7 +7726,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 175
|
||||
"__id__": 176
|
||||
},
|
||||
"_enabled": true,
|
||||
"_useOriginalSize": false,
|
||||
@ -7742,7 +7758,7 @@
|
||||
"_level": 3,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 178
|
||||
"__id__": 179
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
@ -7795,7 +7811,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 177
|
||||
"__id__": 178
|
||||
},
|
||||
"_enabled": true,
|
||||
"_useOriginalSize": false,
|
||||
@ -7851,15 +7867,15 @@
|
||||
},
|
||||
"_enabled": true,
|
||||
"addressLabel": {
|
||||
"__id__": 176
|
||||
"__id__": 177
|
||||
},
|
||||
"balanceLabel": {
|
||||
"__id__": 172
|
||||
"__id__": 173
|
||||
},
|
||||
"qrNode": null,
|
||||
"avatar": {
|
||||
"__id__": 148
|
||||
"__id__": 146
|
||||
},
|
||||
"parentNode": null,
|
||||
"_id": "8bO0XBvlFDPJ87FOgdOxUH"
|
||||
},
|
||||
{
|
||||
@ -7937,7 +7953,6 @@
|
||||
"qrPreb": {
|
||||
"__uuid__": "0f14a371-be16-44a1-adcf-319d54c7ba3d"
|
||||
},
|
||||
"menuPanel": null,
|
||||
"_id": "a8YbO7l9lF95gWk3JRycGs"
|
||||
},
|
||||
{
|
||||
@ -7966,7 +7981,7 @@
|
||||
},
|
||||
"_enabled": true,
|
||||
"webview": {
|
||||
"__id__": 186
|
||||
"__id__": 187
|
||||
},
|
||||
"debugText": {
|
||||
"__id__": 6
|
||||
@ -7979,7 +7994,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 187
|
||||
"__id__": 188
|
||||
},
|
||||
"_enabled": true,
|
||||
"_useOriginalSize": false,
|
||||
@ -7999,7 +8014,7 @@
|
||||
"_level": 1,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 186
|
||||
"__id__": 187
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
|
Loading…
x
Reference in New Issue
Block a user