-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add constractHelper and gen_cid method
- Loading branch information
Showing
15 changed files
with
75 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
declare interface SkUtilsI { | ||
name: 'sk_utils'; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
log(arg: any): void; | ||
storage: string; | ||
save_storage(data: string): void; | ||
gen_cid(data: string | number): string; | ||
} | ||
|
||
declare const __sk_utils__: SkUtilsI; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
(globalThis as any).__sk_utils__ = {}; | ||
|
||
export type ContractFuncReruen<T> = Promise<{ | ||
origin: T; | ||
trans: string; | ||
}>; | ||
|
||
export class SliceDb<T> { | ||
db: Map<string, T> = new Map(); | ||
|
||
get = this.db.get; | ||
set = this.db.set; | ||
has = this.db.has; | ||
delete = this.db.delete; | ||
} | ||
|
||
export const createSliceDb: <T>() => SliceDb<T> = () => { | ||
return new SliceDb(); | ||
}; | ||
|
||
export const hash = (str: string): string => { | ||
return __sk_utils__.gen_cid(str); | ||
}; | ||
|
||
export const log = __sk_utils__.log; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/// <reference types="vite/client" /> | ||
/// <reference types="@trustack/common/config" /> | ||
/// <reference types="@trustack/contract/src/contract" /> | ||
declare const __privateConfigs__: PrivateConfigs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,8 @@ | ||
import type { Address } from './mate/address.js'; | ||
// import type { Transaction } from './mate/transaction.js'; | ||
|
||
// export type SliceKeyType = 'base58' | 'base32'; | ||
|
||
// export namespace ConstractHelper { | ||
// export type SliceDb<T> = { | ||
// get: (key: string) => T; | ||
// has: (key: string) => boolean; | ||
// delete: (key: string) => void; | ||
// set: (key: string, value: T) => void; | ||
// }; | ||
// // export type ContractResultItem = CRI; | ||
// export type ContractFuncReruen<T> = Promise<{ | ||
// origin: T; | ||
// trans: Transaction; | ||
// }>; | ||
// } | ||
|
||
// class SliceDb<T> implements ConstractHelper.SliceDb<T> { | ||
// constructor(keyType: SliceKeyType) { | ||
// this.keyType = keyType; | ||
// } | ||
// // TODO 用keyType,用来做分片存储 | ||
// keyType: SliceKeyType; | ||
// db: Map<string, T> = new Map(); | ||
|
||
// get = this.db.get as ConstractHelper.SliceDb<T>['get']; | ||
// set = this.db.set; | ||
// has = this.db.has; | ||
// delete = this.db.delete; | ||
// } | ||
|
||
// const createSliceDb = <T>(keyType: SliceKeyType): SliceDb<T> => { | ||
// return new SliceDb<T>(keyType); | ||
// }; | ||
|
||
// const hash = (_str: string): void => { | ||
// // return sk.genCidString(str); | ||
// }; | ||
|
||
export class BaseContract { | ||
msg = { | ||
sender: {} as Address, | ||
ts: 0, | ||
}; | ||
} | ||
// export const constractHelper = { | ||
// createSliceDb, | ||
// hash, | ||
// // eslint-disable-next-line no-console | ||
// log: console.log, | ||
// }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.