@wkalidev/trivia-quest-sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +119 -0
- package/package.json +35 -0
- package/sdk/index.d.ts +161 -0
- package/sdk/index.d.ts.map +1 -0
- package/sdk/index.js +160 -0
- package/sdk/index.js.map +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Trivia Q ๐ฎ
|
|
2
|
+
|
|
3
|
+
> Play. Learn. Earn on Celo.
|
|
4
|
+
|
|
5
|
+
Trivia Q is a blockchain-powered quiz game built on Celo where players earn real CELO rewards by answering questions about African culture, geography, Web3, science, sports, and general knowledge.
|
|
6
|
+
|
|
7
|
+
## ๐ Why Africa?
|
|
8
|
+
|
|
9
|
+
Celo's mission is financial inclusion for the unbanked. With 57% of African adults lacking bank accounts but owning smartphones, MiniPay is the perfect gateway. Trivia Q brings fun, education, and real micro-rewards to this audience.
|
|
10
|
+
|
|
11
|
+
## ๐ Live Demo
|
|
12
|
+
|
|
13
|
+
๐ [trivia-quest-eight.vercel.app](https://trivia-quest-eight.vercel.app)
|
|
14
|
+
|
|
15
|
+
## ๐ฎ Game Features
|
|
16
|
+
|
|
17
|
+
- โ
446 questions dans 6 catรฉgories
|
|
18
|
+
- โ
10 questions alรฉatoires par partie
|
|
19
|
+
- โ
Timer de 15 secondes par question
|
|
20
|
+
- โ
Systรจme de Streak x2 / x3 multiplicateur de points
|
|
21
|
+
- โ
Animations Framer Motion
|
|
22
|
+
- โ
Sons & feedback audio (๐/๐ toggle)
|
|
23
|
+
- โ
Leaderboard on-chain en temps rรฉel
|
|
24
|
+
- โ
Support 4 langues : ๐ซ๐ท FR / ๐ฌ๐ง EN / ๐ช๐ธ ES / ๐ฎ๐น IT
|
|
25
|
+
- โ
MiniPay compatible (dรฉtection automatique)
|
|
26
|
+
- โ
PWA installable sur Android
|
|
27
|
+
|
|
28
|
+
## ๐ Question Categories
|
|
29
|
+
|
|
30
|
+
| Catรฉgorie | Nb questions |
|
|
31
|
+
|---|---|
|
|
32
|
+
| ๐ Gรฉographie Africaine | ~80 |
|
|
33
|
+
| ๐ฐ Web3 & Crypto | ~100 |
|
|
34
|
+
| ๐ Histoire & Culture | ~60 |
|
|
35
|
+
| ๐ฌ Science & Tech | ~80 |
|
|
36
|
+
| โฝ Sports | ~40 |
|
|
37
|
+
| ๐ Culture Gรฉnรฉrale | ~86 |
|
|
38
|
+
|
|
39
|
+
## ๐๏ธ Architecture
|
|
40
|
+
|
|
41
|
+
- **Smart Contract** โ Solidity 0.8.20 + OpenZeppelin sur Celo Mainnet
|
|
42
|
+
- **Frontend** โ Next.js 16 + TypeScript + TailwindCSS
|
|
43
|
+
- **Animations** โ Framer Motion
|
|
44
|
+
- **Wallet** โ RainbowKit + Wagmi + Viem + MiniPay hook
|
|
45
|
+
- **i18n** โ next-intl (FR, EN, ES, IT)
|
|
46
|
+
- **Deploy** โ Vercel
|
|
47
|
+
|
|
48
|
+
## ๐ Smart Contracts
|
|
49
|
+
|
|
50
|
+
| Network | Address |
|
|
51
|
+
|---|---|
|
|
52
|
+
| Celo Mainnet | `0xb215c82de33f98b270455f21f7edb7780da0d47d` |
|
|
53
|
+
| Celo Sepolia (testnet) | `0x50b20728ba0ad803679b5428f267c89aede9a378` |
|
|
54
|
+
|
|
55
|
+
## ๐ฑ MiniPay Compatible
|
|
56
|
+
|
|
57
|
+
Trivia Q detects MiniPay automatically and connects the wallet without any popup โ seamless UX for mobile users in Africa.
|
|
58
|
+
|
|
59
|
+
## ๐ฅ Streak System
|
|
60
|
+
|
|
61
|
+
| Streak | Multiplicateur | Points par bonne rรฉponse |
|
|
62
|
+
|---|---|---|
|
|
63
|
+
| 0-2 | x1 | 100 pts |
|
|
64
|
+
| 3-4 | x2 ๐ฅ๐ฅ | 200 pts |
|
|
65
|
+
| 5+ | x3 ๐ฅ๐ฅ๐ฅ | 300 pts |
|
|
66
|
+
|
|
67
|
+
## ๐ Leaderboard On-Chain
|
|
68
|
+
|
|
69
|
+
Le leaderboard est stockรฉ directement sur la blockchain Celo. Chaque joueur accumule des points, et les 10 meilleurs sont affichรฉs en temps rรฉel.
|
|
70
|
+
|
|
71
|
+
## ๐ Multi-Language Support
|
|
72
|
+
|
|
73
|
+
| Language | Code |
|
|
74
|
+
|---|---|
|
|
75
|
+
| ๐ซ๐ท Franรงais | fr |
|
|
76
|
+
| ๐ฌ๐ง English | en |
|
|
77
|
+
| ๐ช๐ธ Espaรฑol | es |
|
|
78
|
+
| ๐ฎ๐น Italiano | it |
|
|
79
|
+
|
|
80
|
+
## ๐ ๏ธ Local Setup
|
|
81
|
+
```bash
|
|
82
|
+
# Clone
|
|
83
|
+
git clone https://github.com/wkalidev/trivia-quest.git
|
|
84
|
+
cd trivia-quest
|
|
85
|
+
|
|
86
|
+
# Frontend
|
|
87
|
+
cd frontend
|
|
88
|
+
yarn install
|
|
89
|
+
yarn dev
|
|
90
|
+
|
|
91
|
+
# Contracts
|
|
92
|
+
cd ../contracts
|
|
93
|
+
npm install
|
|
94
|
+
npx hardhat compile
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## ๐ฏ Proof of Ship Checklist
|
|
98
|
+
|
|
99
|
+
- โ
Build For MiniPay โ MiniPay hook integrated
|
|
100
|
+
- โ
Deploy On Celo โ Smart contract on Celo Mainnet
|
|
101
|
+
- โ
Prove Your Humanity โ Coinbase Verification
|
|
102
|
+
- โ
Submit Your Project
|
|
103
|
+
|
|
104
|
+
## ๐ Tech Stack
|
|
105
|
+
|
|
106
|
+
| Layer | Tech |
|
|
107
|
+
|---|---|
|
|
108
|
+
| Blockchain | Celo Mainnet |
|
|
109
|
+
| Smart Contract | Solidity 0.8.20 + OpenZeppelin |
|
|
110
|
+
| Frontend | Next.js 16 + TypeScript |
|
|
111
|
+
| Styling | TailwindCSS |
|
|
112
|
+
| Animations | Framer Motion |
|
|
113
|
+
| Web3 | Wagmi + Viem + RainbowKit |
|
|
114
|
+
| i18n | next-intl |
|
|
115
|
+
| Deploy | Vercel |
|
|
116
|
+
|
|
117
|
+
## ๐ค Author
|
|
118
|
+
|
|
119
|
+
Built by [@wkalidev](https://github.com/wkalidev) for Celo Proof of Ship โ April 2026
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wkalidev/trivia-quest-sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "SDK for TriviaQuest - Blockchain quiz game on Celo",
|
|
5
|
+
"main": "sdk/index.js",
|
|
6
|
+
"types": "sdk/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"sdk"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build:sdk": "tsc -p tsconfig.sdk.json"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"celo",
|
|
15
|
+
"blockchain",
|
|
16
|
+
"quiz",
|
|
17
|
+
"web3",
|
|
18
|
+
"trivia",
|
|
19
|
+
"minipay",
|
|
20
|
+
"gamefi"
|
|
21
|
+
],
|
|
22
|
+
"author": "wkalidev",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "https://github.com/wkalidev/trivia-quest.git"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://trivia-quest-eight.vercel.app",
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"viem": "^2.0.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"typescript": "^6.0.2"
|
|
34
|
+
}
|
|
35
|
+
}
|
package/sdk/index.d.ts
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
export declare const CONTRACT_ADDRESS_MAINNET: "0xb215c82de33f98b270455f21f7edb7780da0d47d";
|
|
2
|
+
export declare const CONTRACT_ADDRESS_TESTNET: "0x50b20728ba0ad803679b5428f267c89aede9a378";
|
|
3
|
+
export declare const CONTRACT_ABI: readonly [{
|
|
4
|
+
readonly name: "joinRound";
|
|
5
|
+
readonly type: "function";
|
|
6
|
+
readonly stateMutability: "payable";
|
|
7
|
+
readonly inputs: readonly [];
|
|
8
|
+
readonly outputs: readonly [];
|
|
9
|
+
}, {
|
|
10
|
+
readonly name: "getCurrentRound";
|
|
11
|
+
readonly type: "function";
|
|
12
|
+
readonly stateMutability: "view";
|
|
13
|
+
readonly inputs: readonly [];
|
|
14
|
+
readonly outputs: readonly [{
|
|
15
|
+
readonly type: "tuple";
|
|
16
|
+
readonly components: readonly [{
|
|
17
|
+
readonly name: "id";
|
|
18
|
+
readonly type: "uint256";
|
|
19
|
+
}, {
|
|
20
|
+
readonly name: "prizePool";
|
|
21
|
+
readonly type: "uint256";
|
|
22
|
+
}, {
|
|
23
|
+
readonly name: "startTime";
|
|
24
|
+
readonly type: "uint256";
|
|
25
|
+
}, {
|
|
26
|
+
readonly name: "endTime";
|
|
27
|
+
readonly type: "uint256";
|
|
28
|
+
}, {
|
|
29
|
+
readonly name: "winner";
|
|
30
|
+
readonly type: "address";
|
|
31
|
+
}, {
|
|
32
|
+
readonly name: "finished";
|
|
33
|
+
readonly type: "bool";
|
|
34
|
+
}];
|
|
35
|
+
}];
|
|
36
|
+
}, {
|
|
37
|
+
readonly name: "entryFee";
|
|
38
|
+
readonly type: "function";
|
|
39
|
+
readonly stateMutability: "view";
|
|
40
|
+
readonly inputs: readonly [];
|
|
41
|
+
readonly outputs: readonly [{
|
|
42
|
+
readonly type: "uint256";
|
|
43
|
+
}];
|
|
44
|
+
}, {
|
|
45
|
+
readonly name: "getLeaderboard";
|
|
46
|
+
readonly type: "function";
|
|
47
|
+
readonly stateMutability: "view";
|
|
48
|
+
readonly inputs: readonly [];
|
|
49
|
+
readonly outputs: readonly [{
|
|
50
|
+
readonly type: "tuple[]";
|
|
51
|
+
readonly components: readonly [{
|
|
52
|
+
readonly name: "player";
|
|
53
|
+
readonly type: "address";
|
|
54
|
+
}, {
|
|
55
|
+
readonly name: "totalPoints";
|
|
56
|
+
readonly type: "uint256";
|
|
57
|
+
}, {
|
|
58
|
+
readonly name: "bestScore";
|
|
59
|
+
readonly type: "uint256";
|
|
60
|
+
}, {
|
|
61
|
+
readonly name: "gamesPlayed";
|
|
62
|
+
readonly type: "uint256";
|
|
63
|
+
}];
|
|
64
|
+
}];
|
|
65
|
+
}, {
|
|
66
|
+
readonly name: "getPlayerStats";
|
|
67
|
+
readonly type: "function";
|
|
68
|
+
readonly stateMutability: "view";
|
|
69
|
+
readonly inputs: readonly [{
|
|
70
|
+
readonly name: "player";
|
|
71
|
+
readonly type: "address";
|
|
72
|
+
}];
|
|
73
|
+
readonly outputs: readonly [{
|
|
74
|
+
readonly type: "tuple";
|
|
75
|
+
readonly components: readonly [{
|
|
76
|
+
readonly name: "score";
|
|
77
|
+
readonly type: "uint256";
|
|
78
|
+
}, {
|
|
79
|
+
readonly name: "totalWinnings";
|
|
80
|
+
readonly type: "uint256";
|
|
81
|
+
}, {
|
|
82
|
+
readonly name: "totalPoints";
|
|
83
|
+
readonly type: "uint256";
|
|
84
|
+
}, {
|
|
85
|
+
readonly name: "gamesPlayed";
|
|
86
|
+
readonly type: "uint256";
|
|
87
|
+
}, {
|
|
88
|
+
readonly name: "bestScore";
|
|
89
|
+
readonly type: "uint256";
|
|
90
|
+
}, {
|
|
91
|
+
readonly name: "exists";
|
|
92
|
+
readonly type: "bool";
|
|
93
|
+
}];
|
|
94
|
+
}];
|
|
95
|
+
}, {
|
|
96
|
+
readonly name: "getTotalPlayers";
|
|
97
|
+
readonly type: "function";
|
|
98
|
+
readonly stateMutability: "view";
|
|
99
|
+
readonly inputs: readonly [];
|
|
100
|
+
readonly outputs: readonly [{
|
|
101
|
+
readonly type: "uint256";
|
|
102
|
+
}];
|
|
103
|
+
}, {
|
|
104
|
+
readonly name: "submitScore";
|
|
105
|
+
readonly type: "function";
|
|
106
|
+
readonly stateMutability: "nonpayable";
|
|
107
|
+
readonly inputs: readonly [{
|
|
108
|
+
readonly name: "player";
|
|
109
|
+
readonly type: "address";
|
|
110
|
+
}, {
|
|
111
|
+
readonly name: "score";
|
|
112
|
+
readonly type: "uint256";
|
|
113
|
+
}, {
|
|
114
|
+
readonly name: "points";
|
|
115
|
+
readonly type: "uint256";
|
|
116
|
+
}];
|
|
117
|
+
readonly outputs: readonly [];
|
|
118
|
+
}];
|
|
119
|
+
export type LeaderboardEntry = {
|
|
120
|
+
player: string;
|
|
121
|
+
totalPoints: bigint;
|
|
122
|
+
bestScore: bigint;
|
|
123
|
+
gamesPlayed: bigint;
|
|
124
|
+
};
|
|
125
|
+
export type PlayerStats = {
|
|
126
|
+
score: bigint;
|
|
127
|
+
totalWinnings: bigint;
|
|
128
|
+
totalPoints: bigint;
|
|
129
|
+
gamesPlayed: bigint;
|
|
130
|
+
bestScore: bigint;
|
|
131
|
+
exists: boolean;
|
|
132
|
+
};
|
|
133
|
+
export type Round = {
|
|
134
|
+
id: bigint;
|
|
135
|
+
prizePool: bigint;
|
|
136
|
+
startTime: bigint;
|
|
137
|
+
endTime: bigint;
|
|
138
|
+
winner: string;
|
|
139
|
+
finished: boolean;
|
|
140
|
+
};
|
|
141
|
+
export declare function isMiniPay(): boolean;
|
|
142
|
+
export declare function getMiniPayAccount(): Promise<string | null>;
|
|
143
|
+
export declare function getMultiplier(streak: number): number;
|
|
144
|
+
export declare function calculatePoints(correct: boolean, streak: number): number;
|
|
145
|
+
export declare function getStreakLabel(streak: number): string;
|
|
146
|
+
export declare const CELO_MAINNET: {
|
|
147
|
+
id: number;
|
|
148
|
+
name: string;
|
|
149
|
+
rpcUrl: string;
|
|
150
|
+
explorerUrl: string;
|
|
151
|
+
contractAddress: "0xb215c82de33f98b270455f21f7edb7780da0d47d";
|
|
152
|
+
};
|
|
153
|
+
export declare const CELO_TESTNET: {
|
|
154
|
+
id: number;
|
|
155
|
+
name: string;
|
|
156
|
+
rpcUrl: string;
|
|
157
|
+
explorerUrl: string;
|
|
158
|
+
contractAddress: "0x50b20728ba0ad803679b5428f267c89aede9a378";
|
|
159
|
+
};
|
|
160
|
+
export declare const SDK_VERSION = "1.0.0";
|
|
161
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../sdk-src/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,wBAAwB,EAAG,4CAAqD,CAAC;AAC9F,eAAO,MAAM,wBAAwB,EAAG,4CAAqD,CAAC;AAE9F,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwFf,CAAC;AAGX,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAGF,wBAAgB,SAAS,IAAI,OAAO,CAGnC;AAUD,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAUhE;AAGD,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAIpD;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAGxE;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAKrD;AAGD,eAAO,MAAM,YAAY;;;;;;CAMxB,CAAC;AAEF,eAAO,MAAM,YAAY;;;;;;CAMxB,CAAC;AAEF,eAAO,MAAM,WAAW,UAAU,CAAC"}
|
package/sdk/index.js
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// TriviaQuest SDK
|
|
3
|
+
// Blockchain quiz game on Celo
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.SDK_VERSION = exports.CELO_TESTNET = exports.CELO_MAINNET = exports.CONTRACT_ABI = exports.CONTRACT_ADDRESS_TESTNET = exports.CONTRACT_ADDRESS_MAINNET = void 0;
|
|
6
|
+
exports.isMiniPay = isMiniPay;
|
|
7
|
+
exports.getMiniPayAccount = getMiniPayAccount;
|
|
8
|
+
exports.getMultiplier = getMultiplier;
|
|
9
|
+
exports.calculatePoints = calculatePoints;
|
|
10
|
+
exports.getStreakLabel = getStreakLabel;
|
|
11
|
+
exports.CONTRACT_ADDRESS_MAINNET = "0xb215c82de33f98b270455f21f7edb7780da0d47d";
|
|
12
|
+
exports.CONTRACT_ADDRESS_TESTNET = "0x50b20728ba0ad803679b5428f267c89aede9a378";
|
|
13
|
+
exports.CONTRACT_ABI = [
|
|
14
|
+
{
|
|
15
|
+
name: "joinRound",
|
|
16
|
+
type: "function",
|
|
17
|
+
stateMutability: "payable",
|
|
18
|
+
inputs: [],
|
|
19
|
+
outputs: [],
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: "getCurrentRound",
|
|
23
|
+
type: "function",
|
|
24
|
+
stateMutability: "view",
|
|
25
|
+
inputs: [],
|
|
26
|
+
outputs: [
|
|
27
|
+
{
|
|
28
|
+
type: "tuple",
|
|
29
|
+
components: [
|
|
30
|
+
{ name: "id", type: "uint256" },
|
|
31
|
+
{ name: "prizePool", type: "uint256" },
|
|
32
|
+
{ name: "startTime", type: "uint256" },
|
|
33
|
+
{ name: "endTime", type: "uint256" },
|
|
34
|
+
{ name: "winner", type: "address" },
|
|
35
|
+
{ name: "finished", type: "bool" },
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: "entryFee",
|
|
42
|
+
type: "function",
|
|
43
|
+
stateMutability: "view",
|
|
44
|
+
inputs: [],
|
|
45
|
+
outputs: [{ type: "uint256" }],
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: "getLeaderboard",
|
|
49
|
+
type: "function",
|
|
50
|
+
stateMutability: "view",
|
|
51
|
+
inputs: [],
|
|
52
|
+
outputs: [
|
|
53
|
+
{
|
|
54
|
+
type: "tuple[]",
|
|
55
|
+
components: [
|
|
56
|
+
{ name: "player", type: "address" },
|
|
57
|
+
{ name: "totalPoints", type: "uint256" },
|
|
58
|
+
{ name: "bestScore", type: "uint256" },
|
|
59
|
+
{ name: "gamesPlayed", type: "uint256" },
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: "getPlayerStats",
|
|
66
|
+
type: "function",
|
|
67
|
+
stateMutability: "view",
|
|
68
|
+
inputs: [{ name: "player", type: "address" }],
|
|
69
|
+
outputs: [
|
|
70
|
+
{
|
|
71
|
+
type: "tuple",
|
|
72
|
+
components: [
|
|
73
|
+
{ name: "score", type: "uint256" },
|
|
74
|
+
{ name: "totalWinnings", type: "uint256" },
|
|
75
|
+
{ name: "totalPoints", type: "uint256" },
|
|
76
|
+
{ name: "gamesPlayed", type: "uint256" },
|
|
77
|
+
{ name: "bestScore", type: "uint256" },
|
|
78
|
+
{ name: "exists", type: "bool" },
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: "getTotalPlayers",
|
|
85
|
+
type: "function",
|
|
86
|
+
stateMutability: "view",
|
|
87
|
+
inputs: [],
|
|
88
|
+
outputs: [{ type: "uint256" }],
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: "submitScore",
|
|
92
|
+
type: "function",
|
|
93
|
+
stateMutability: "nonpayable",
|
|
94
|
+
inputs: [
|
|
95
|
+
{ name: "player", type: "address" },
|
|
96
|
+
{ name: "score", type: "uint256" },
|
|
97
|
+
{ name: "points", type: "uint256" },
|
|
98
|
+
],
|
|
99
|
+
outputs: [],
|
|
100
|
+
},
|
|
101
|
+
];
|
|
102
|
+
// โโ MiniPay Utils โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
103
|
+
function isMiniPay() {
|
|
104
|
+
if (typeof window === "undefined")
|
|
105
|
+
return false;
|
|
106
|
+
return window.navigator.userAgent.includes("MiniPay");
|
|
107
|
+
}
|
|
108
|
+
async function getMiniPayAccount() {
|
|
109
|
+
if (!isMiniPay())
|
|
110
|
+
return null;
|
|
111
|
+
try {
|
|
112
|
+
const ethereum = window.ethereum;
|
|
113
|
+
if (!ethereum)
|
|
114
|
+
return null;
|
|
115
|
+
const accounts = await ethereum.request({ method: "eth_requestAccounts" });
|
|
116
|
+
return accounts[0] ?? null;
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// โโ Score Utils โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
123
|
+
function getMultiplier(streak) {
|
|
124
|
+
if (streak >= 5)
|
|
125
|
+
return 3;
|
|
126
|
+
if (streak >= 3)
|
|
127
|
+
return 2;
|
|
128
|
+
return 1;
|
|
129
|
+
}
|
|
130
|
+
function calculatePoints(correct, streak) {
|
|
131
|
+
if (!correct)
|
|
132
|
+
return 0;
|
|
133
|
+
return 100 * getMultiplier(streak + 1);
|
|
134
|
+
}
|
|
135
|
+
function getStreakLabel(streak) {
|
|
136
|
+
if (streak >= 5)
|
|
137
|
+
return "๐ฅ๐ฅ๐ฅ x3 MEGA";
|
|
138
|
+
if (streak >= 3)
|
|
139
|
+
return "๐ฅ๐ฅ x2 HOT";
|
|
140
|
+
if (streak >= 1)
|
|
141
|
+
return "๐ฅ Streak";
|
|
142
|
+
return "";
|
|
143
|
+
}
|
|
144
|
+
// โโ Network Config โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
145
|
+
exports.CELO_MAINNET = {
|
|
146
|
+
id: 42220,
|
|
147
|
+
name: "Celo Mainnet",
|
|
148
|
+
rpcUrl: "https://forno.celo.org",
|
|
149
|
+
explorerUrl: "https://celoscan.io",
|
|
150
|
+
contractAddress: exports.CONTRACT_ADDRESS_MAINNET,
|
|
151
|
+
};
|
|
152
|
+
exports.CELO_TESTNET = {
|
|
153
|
+
id: 11142220,
|
|
154
|
+
name: "Celo Sepolia",
|
|
155
|
+
rpcUrl: "https://forno.celo-sepolia.celo-testnet.org",
|
|
156
|
+
explorerUrl: "https://sepolia.celoscan.io",
|
|
157
|
+
contractAddress: exports.CONTRACT_ADDRESS_TESTNET,
|
|
158
|
+
};
|
|
159
|
+
exports.SDK_VERSION = "1.0.0";
|
|
160
|
+
//# sourceMappingURL=index.js.map
|
package/sdk/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../sdk-src/index.ts"],"names":[],"mappings":";AAAA,kBAAkB;AAClB,+BAA+B;;;AA0H/B,8BAGC;AAUD,8CAUC;AAGD,sCAIC;AAED,0CAGC;AAED,wCAKC;AAlKY,QAAA,wBAAwB,GAAG,4CAAqD,CAAC;AACjF,QAAA,wBAAwB,GAAG,4CAAqD,CAAC;AAEjF,QAAA,YAAY,G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