@jetthai/cuora 1.1.425 → 1.1.426-dev.2

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/CHANGELOG.md CHANGED
@@ -2,11 +2,137 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.1.426-dev.2](https://github.com/jetthai/cuora-module/compare/v1.1.426-dev.1...v1.1.426-dev.2) (2026-04-01)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **scripts:** add CHANGELOG.md to prettierignore to prevent format conflict with standard-version ([d254b54](https://github.com/jetthai/cuora-module/commit/d254b54335c06b69f8af54d1bdb3f2995f75436f))
11
+
12
+ ### [1.1.426-dev.1](https://github.com/jetthai/cuora-module/compare/v1.1.426-dev.0...v1.1.426-dev.1) (2026-04-01)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * **scripts:** format and stage changes before standard-version to prevent rebase failure ([b5cb701](https://github.com/jetthai/cuora-module/commit/b5cb70155a0eaf516f96b76e6790cf57d80886a2))
18
+
19
+ ### [1.1.426-dev.0](https://github.com/jetthai/cuora-module/compare/v1.1.425...v1.1.426-dev.0) (2026-04-01)
20
+
21
+ ### Features
22
+
23
+ - **scripts:** auto pull --rebase before push in branch-auto-npm-publish ([761f5c8](https://github.com/jetthai/cuora-module/commit/761f5c8ac653d0a1578cbc610b7c9b1798066875))
24
+ - **scripts:** extend clean-tags to delete orphan and master-merged tags ([f24bc33](https://github.com/jetthai/cuora-module/commit/f24bc3337bcf558e67e613818ba5a79983675a26))
25
+
26
+ ### Bug Fixes
27
+
28
+ - **scripts:** add --no-verify to git push in branch-auto-npm-publish to prevent pre-push hook infinite recursion ([4214aee](https://github.com/jetthai/cuora-module/commit/4214aeeed05834bce2537acd6ef816719c388b64))
29
+ - **scripts:** prevent infinite recursion in clean-tags pre-push hook ([5e9db84](https://github.com/jetthai/cuora-module/commit/5e9db84f1a655318b73839ab9a215f4dbe980772))
30
+
31
+ ### [1.1.425-dev.4](https://github.com/jetthai/cuora-module/compare/v1.1.425-dev.3...v1.1.425-dev.4) (2026-03-31)
32
+
33
+ ### [1.1.425-dev.3](https://github.com/jetthai/cuora-module/compare/v1.1.425...v1.1.425-dev.3) (2026-03-31)
34
+
35
+ ### Features
36
+
37
+ - **scripts:** auto pull --rebase before push in branch-auto-npm-publish ([761f5c8](https://github.com/jetthai/cuora-module/commit/761f5c8ac653d0a1578cbc610b7c9b1798066875))
38
+ - **scripts:** extend clean-tags to delete orphan and master-merged tags ([f24bc33](https://github.com/jetthai/cuora-module/commit/f24bc3337bcf558e67e613818ba5a79983675a26))
39
+
40
+ ### Bug Fixes
41
+
42
+ - **scripts:** add --no-verify to git push in branch-auto-npm-publish to prevent pre-push hook infinite recursion ([4214aee](https://github.com/jetthai/cuora-module/commit/4214aeeed05834bce2537acd6ef816719c388b64))
43
+ - **scripts:** prevent infinite recursion in clean-tags pre-push hook ([5e9db84](https://github.com/jetthai/cuora-module/commit/5e9db84f1a655318b73839ab9a215f4dbe980772))
44
+
45
+ ### [1.1.425-dev.2](https://github.com/jetthai/cuora-module/compare/v1.1.425-dev.1...v1.1.425-dev.2) (2026-03-31)
46
+
47
+ ### [1.1.425-dev.1](https://github.com/jetthai/cuora-module/compare/v1.1.425-dev.0...v1.1.425-dev.1) (2026-03-30)
48
+
49
+ ### [1.1.425-dev.0](https://github.com/jetthai/cuora-module/compare/v1.1.425...v1.1.425-dev.0) (2026-03-30)
50
+
51
+ ### Features
52
+
53
+ - **scripts:** auto pull --rebase before push in branch-auto-npm-publish ([761f5c8](https://github.com/jetthai/cuora-module/commit/761f5c8ac653d0a1578cbc610b7c9b1798066875))
54
+ - **scripts:** extend clean-tags to delete orphan and master-merged tags ([f24bc33](https://github.com/jetthai/cuora-module/commit/f24bc3337bcf558e67e613818ba5a79983675a26))
55
+
56
+ ### Bug Fixes
57
+
58
+ - **scripts:** add --no-verify to git push in branch-auto-npm-publish to prevent pre-push hook infinite recursion ([4214aee](https://github.com/jetthai/cuora-module/commit/4214aeeed05834bce2537acd6ef816719c388b64))
59
+ - **scripts:** prevent infinite recursion in clean-tags pre-push hook ([5e9db84](https://github.com/jetthai/cuora-module/commit/5e9db84f1a655318b73839ab9a215f4dbe980772))
60
+
5
61
  ### [1.1.425](https://github.com/jetthai/cuora-module/compare/v1.1.424...v1.1.425) (2026-03-23)
6
62
 
7
63
  ### [1.1.424](https://github.com/jetthai/cuora-module/compare/v1.1.423...v1.1.424) (2026-03-17)
8
64
 
9
- ### [1.1.423](https://github.com/jetthai/cuora-module/compare/v1.1.422...v1.1.423) (2026-03-17)
65
+ ### [1.1.422-dev-2](https://github.com/jetthai/cuora-module/compare/v1.1.422-dev-1...v1.1.422-dev-2) (2026-03-17)
66
+
67
+ ### [1.1.422-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.422...v1.1.422-dev-1) (2026-03-16)
68
+
69
+ ### [1.1.413-dev-11](https://github.com/jetthai/cuora-module/compare/v1.1.413-dev-10...v1.1.413-dev-11) (2026-03-12)
70
+
71
+ ### [1.1.413-dev-10](https://github.com/jetthai/cuora-module/compare/v1.1.413-dev-9...v1.1.413-dev-10) (2026-03-11)
72
+
73
+ ### [1.1.413-dev-9](https://github.com/jetthai/cuora-module/compare/v1.1.421...v1.1.413-dev-9) (2026-03-11)
74
+
75
+ ### [1.1.413-dev-8](https://github.com/jetthai/cuora-module/compare/v1.1.420...v1.1.413-dev-8) (2026-03-10)
76
+
77
+ ### [1.1.413-dev-7](https://github.com/jetthai/cuora-module/compare/v1.1.413-6...v1.1.413-dev-7) (2026-03-06)
78
+
79
+ ### [1.1.413-6](https://github.com/jetthai/cuora-module/compare/v1.1.416...v1.1.413-6) (2026-03-06)
80
+
81
+ ### [1.1.413-5](https://github.com/jetthai/cuora-module/compare/v1.1.413...v1.1.413-5) (2026-03-05)
82
+
83
+ ### [1.1.422-dev-2](https://github.com/jetthai/cuora-module/compare/v1.1.422-dev-1...v1.1.422-dev-2) (2026-03-17)
84
+
85
+ ### [1.1.422-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.422...v1.1.422-dev-1) (2026-03-16)
86
+
87
+ ### [1.1.413-dev-11](https://github.com/jetthai/cuora-module/compare/v1.1.413-dev-10...v1.1.413-dev-11) (2026-03-12)
88
+
89
+ ### [1.1.413-dev-10](https://github.com/jetthai/cuora-module/compare/v1.1.413-dev-9...v1.1.413-dev-10) (2026-03-11)
90
+
91
+ ### [1.1.413-dev-9](https://github.com/jetthai/cuora-module/compare/v1.1.421...v1.1.413-dev-9) (2026-03-11)
92
+
93
+ ### [1.1.413-dev-8](https://github.com/jetthai/cuora-module/compare/v1.1.420...v1.1.413-dev-8) (2026-03-10)
94
+
95
+ ### [1.1.413-dev-7](https://github.com/jetthai/cuora-module/compare/v1.1.413-6...v1.1.413-dev-7) (2026-03-06)
96
+
97
+ ### [1.1.413-6](https://github.com/jetthai/cuora-module/compare/v1.1.416...v1.1.413-6) (2026-03-06)
98
+
99
+ ### [1.1.413-5](https://github.com/jetthai/cuora-module/compare/v1.1.413...v1.1.413-5) (2026-03-05)
100
+
101
+ ### [1.1.422-dev-2](https://github.com/jetthai/cuora-module/compare/v1.1.422-dev-1...v1.1.422-dev-2) (2026-03-17)
102
+
103
+ ### [1.1.422-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.422...v1.1.422-dev-1) (2026-03-16)
104
+
105
+ ### [1.1.413-dev-11](https://github.com/jetthai/cuora-module/compare/v1.1.413-dev-10...v1.1.413-dev-11) (2026-03-12)
106
+
107
+ ### [1.1.413-dev-10](https://github.com/jetthai/cuora-module/compare/v1.1.413-dev-9...v1.1.413-dev-10) (2026-03-11)
108
+
109
+ ### [1.1.413-dev-9](https://github.com/jetthai/cuora-module/compare/v1.1.421...v1.1.413-dev-9) (2026-03-11)
110
+
111
+ ### [1.1.413-dev-8](https://github.com/jetthai/cuora-module/compare/v1.1.420...v1.1.413-dev-8) (2026-03-10)
112
+
113
+ ### [1.1.413-dev-7](https://github.com/jetthai/cuora-module/compare/v1.1.413-6...v1.1.413-dev-7) (2026-03-06)
114
+
115
+ ### [1.1.413-6](https://github.com/jetthai/cuora-module/compare/v1.1.416...v1.1.413-6) (2026-03-06)
116
+
117
+ ### [1.1.413-5](https://github.com/jetthai/cuora-module/compare/v1.1.413...v1.1.413-5) (2026-03-05)
118
+
119
+ ### [1.1.422-dev-2](https://github.com/jetthai/cuora-module/compare/v1.1.422-dev-1...v1.1.422-dev-2) (2026-03-17)
120
+
121
+ ### [1.1.422-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.422...v1.1.422-dev-1) (2026-03-16)
122
+
123
+ ### [1.1.413-dev-11](https://github.com/jetthai/cuora-module/compare/v1.1.413-dev-10...v1.1.413-dev-11) (2026-03-12)
124
+
125
+ ### [1.1.413-dev-10](https://github.com/jetthai/cuora-module/compare/v1.1.413-dev-9...v1.1.413-dev-10) (2026-03-11)
126
+
127
+ ### [1.1.413-dev-9](https://github.com/jetthai/cuora-module/compare/v1.1.421...v1.1.413-dev-9) (2026-03-11)
128
+
129
+ ### [1.1.413-dev-8](https://github.com/jetthai/cuora-module/compare/v1.1.420...v1.1.413-dev-8) (2026-03-10)
130
+
131
+ ### [1.1.413-dev-7](https://github.com/jetthai/cuora-module/compare/v1.1.413-6...v1.1.413-dev-7) (2026-03-06)
132
+
133
+ ### [1.1.413-6](https://github.com/jetthai/cuora-module/compare/v1.1.416...v1.1.413-6) (2026-03-06)
134
+
135
+ ### [1.1.413-5](https://github.com/jetthai/cuora-module/compare/v1.1.413...v1.1.413-5) (2026-03-05)
10
136
 
11
137
  ### [1.1.422](https://github.com/jetthai/cuora-module/compare/v1.1.421...v1.1.422) (2026-03-16)
12
138
 
package/README.md CHANGED
@@ -167,11 +167,45 @@ src/
167
167
  # 格式化程式碼(Prettier)
168
168
  npm run format
169
169
 
170
- # 發佈新版本(standard-version + git push + npm publish)
170
+ # master 分支:發佈新版本(standard-version + git push + npm publish)
171
171
  npm run release
172
172
 
173
- # 發佈並標記為 latest
173
+ # master 分支:發佈並標記為 latest
174
174
  npm run release:latest
175
+
176
+ # dev/qa 分支:手動觸發版本發佈
177
+ npm run release:dev
178
+ npm run release:qa
175
179
  ```
176
180
 
177
181
  程式碼風格由 Prettier 管理(無分號、單引號、尾隨逗號 ES5、2 空格縮排、150 字元行寬),Husky pre-commit hook 會在每次提交時自動格式化。
182
+
183
+ ### dev / qa 分支版本發佈
184
+
185
+ 在 `dev` 或 `qa` 分支執行 `git push` 時,Husky `pre-push` hook 會自動觸發三階段流程:
186
+
187
+ ```
188
+ git push → auto-version.sh(流程控制)
189
+ ├─ ① auto-version.js → 計算版號(含 historyMax 防倒退)
190
+ ├─ ② standard-version → 更新 CHANGELOG + commit + tag
191
+ └─ ③ branch-auto-npm-publish.js → git push + npm publish
192
+ ```
193
+
194
+ **腳本權責:**
195
+
196
+ | 腳本 | 職責 | 說明 |
197
+ | ------------------------------------ | ---------- | --------------------------------------------------------- |
198
+ | `scripts/auto-version.sh` | 流程控制 | pre-push 入口,串接版號計算 → standard-version → 發佈 |
199
+ | `scripts/auto-version.js` | 版號計算 | 讀取 master 版本 + 掃描 git log 防倒退,stdout 輸出新版號 |
200
+ | `scripts/branch-auto-npm-publish.js` | 推送與發佈 | `git push --follow-tags` + `npm publish --tag {branch}` |
201
+
202
+ **版本號規則:**
203
+
204
+ | 情境 | 範例 |
205
+ | ------------------------------------ | ------------------------------------- |
206
+ | master 為 `1.1.425`,dev 第一次 push | `1.1.425-dev.0` |
207
+ | dev 再次 push | `1.1.425-dev.1`、`1.1.425-dev.2`、... |
208
+ | master 升版至 `1.1.426` 後 | dev 重置為 `1.1.426-dev.0` |
209
+ | qa 分支 | `1.1.425-qa.0`、`1.1.425-qa.1`、... |
210
+
211
+ > **注意**:`pre-push` hook 完成推送後會以 `exit 1` 中止原始 push(因為已推送完成),終端會顯示 push 失敗訊息,但實際發佈已成功。以 `Released x.x.x on {branch}` 訊息為準。
package/package.json CHANGED
@@ -1,12 +1,14 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.425",
3
+ "version": "1.1.426-dev.2",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
7
7
  "scripts": {
8
8
  "release": "standard-version && git push --follow-tags origin master && npm publish",
9
9
  "release:latest": "standard-version && git push --follow-tags origin master && npm publish && npm dist-tag add @jetthai/cuora@$(node -p \"require('./package.json').version\") latest",
10
+ "release:dev": "node scripts/branch-auto-npm-publish.js",
11
+ "release:qa": "node scripts/branch-auto-npm-publish.js",
10
12
  "format": "prettier --write .",
11
13
  "prepare": "husky install"
12
14
  },
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env node
2
+ // Copyright 2024 The Terasology Foundation
3
+
4
+ // Auto version bump for dev/qa branches
5
+ // Format: {master version}-{branch}.{number}
6
+ // Example: master=2.1.1, dev 5th push → 2.1.1-dev.5
7
+ //
8
+ // Called by auto-version.sh (pre-push hook)
9
+ // Outputs new version to stdout; silent exit if no change needed
10
+
11
+ import { execSync } from 'node:child_process'
12
+ import { readFileSync } from 'node:fs'
13
+
14
+ // Only run on dev / qa branches
15
+ const branch = execSync('git rev-parse --abbrev-ref HEAD', { encoding: 'utf8' }).trim()
16
+
17
+ if (branch !== 'dev' && branch !== 'qa') {
18
+ process.exit(0)
19
+ }
20
+
21
+ // Get base version from origin/master, fallback to local master
22
+ let masterVersion
23
+ try {
24
+ masterVersion = JSON.parse(execSync('git show origin/master:package.json', { encoding: 'utf8' })).version
25
+ } catch {
26
+ try {
27
+ masterVersion = JSON.parse(execSync('git show master:package.json', { encoding: 'utf8' })).version
28
+ } catch {
29
+ console.error('Cannot read master package.json version')
30
+ process.exit(1)
31
+ }
32
+ }
33
+
34
+ const currentVersion = JSON.parse(readFileSync('package.json', 'utf8')).version
35
+ const prefix = `${masterVersion}-${branch}.`
36
+ let nextNum = 0
37
+
38
+ // Derive next number from current version
39
+ // e.g. currentVersion="2.1.1-dev.4" → nextNum=5
40
+ if (currentVersion.startsWith(prefix)) {
41
+ const num = parseInt(currentVersion.slice(prefix.length), 10)
42
+ if (!isNaN(num)) nextNum = num + 1
43
+ }
44
+
45
+ // Scan git log for the highest number ever used with this prefix
46
+ // Prevents regression when merges overwrite currentVersion
47
+ // e.g. after merge currentVersion="2.0.9-dev.20", but history has "2.1.1-dev.4"
48
+ // → historyMax=4, nextNum=5 (instead of restarting from 0)
49
+ try {
50
+ const log = execSync(`git log ${branch} --pretty=%s --grep="^${masterVersion}-${branch}\\\\." -n 50`, {
51
+ encoding: 'utf8',
52
+ })
53
+ for (const line of log.trim().split('\n')) {
54
+ if (!line.startsWith(prefix)) continue
55
+ const n = parseInt(line.slice(prefix.length), 10)
56
+ if (!isNaN(n) && n >= nextNum) nextNum = n + 1
57
+ }
58
+ } catch {}
59
+
60
+ const newVersion = `${prefix}${nextNum}`
61
+
62
+ // No change needed
63
+ if (currentVersion === newVersion) {
64
+ process.exit(0)
65
+ }
66
+
67
+ console.log(newVersion)
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env sh
2
+
3
+ # Auto version bump on dev/qa branches
4
+ # Called from pre-push hook — receives remote name as $1
5
+
6
+ REMOTE=${1:-origin}
7
+ BRANCH=$(git rev-parse --abbrev-ref HEAD)
8
+
9
+ if [ "$BRANCH" = "dev" ] || [ "$BRANCH" = "qa" ]; then
10
+ # Compute next prerelease version (scans git log to prevent regression)
11
+ NEXT_VERSION=$(node scripts/auto-version.js)
12
+
13
+ if [ -z "$NEXT_VERSION" ]; then
14
+ echo "Version unchanged, skipping release."
15
+ exit 0
16
+ fi
17
+
18
+ echo "Branch: $BRANCH"
19
+ echo "Next version: $NEXT_VERSION"
20
+
21
+ # Bump version, update CHANGELOG, create commit + tag
22
+ npx standard-version --release-as "$NEXT_VERSION"
23
+
24
+ # Push + npm publish
25
+ node scripts/branch-auto-npm-publish.js "$REMOTE" "$BRANCH"
26
+
27
+ # Abort the original git push (scripts already pushed)
28
+ exit 1
29
+ fi
@@ -0,0 +1,27 @@
1
+ import { execSync } from 'node:child_process'
2
+ import { readFileSync } from 'node:fs'
3
+
4
+ const remote = process.argv[2] || 'origin'
5
+ const branch = process.argv[3] || execSync('git rev-parse --abbrev-ref HEAD', { encoding: 'utf8' }).trim()
6
+
7
+ const { version } = JSON.parse(readFileSync('package.json', 'utf8'))
8
+
9
+ console.log(`Branch: ${branch}`)
10
+ console.log(`Version: ${version}`)
11
+
12
+ // Pull remote changes before push (avoid rejection)
13
+ execSync(`git pull --rebase --no-verify ${remote} ${branch}`, { stdio: 'inherit' })
14
+
15
+ // Push commit and tags
16
+ execSync(`git push --no-verify --follow-tags ${remote} ${branch}`, { stdio: 'inherit' })
17
+
18
+ // Publish to npm with branch dist-tag
19
+ try {
20
+ execSync(`npm publish --tag ${branch}`, { stdio: 'inherit' })
21
+ console.log(`✅ npm publish succeeded: ${version} (tag: ${branch})`)
22
+ } catch {
23
+ console.error(`❌ npm publish failed for ${version}. Please run "npm publish --tag ${branch}" manually.`)
24
+ process.exit(1)
25
+ }
26
+
27
+ console.log(`Released ${version} on ${branch}`)
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env sh
2
+
3
+ # Delete local and remote tags that do NOT match the compliant pattern
4
+ # Compliant pattern: v1.2.3 (e.g., v0.1.0, v1.12.123)
5
+ #
6
+ # Deletion rules (any match triggers deletion):
7
+ # 1. Current branch is dev or qa
8
+ # 2. Tag's commit is not reachable from any branch
9
+ # 3. Tag's commit is already merged into master
10
+ PATTERN="^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$"
11
+
12
+ BRANCH=$(git rev-parse --abbrev-ref HEAD)
13
+
14
+ # Find the latest tag (by creation date) regardless of format
15
+ LATEST_TAG=$(git tag -l --sort=-creatordate | head -n 1)
16
+
17
+ # Collect non-compliant tags
18
+ TAGS=$(git tag -l | grep -vE "$PATTERN")
19
+
20
+ if [ -z "$TAGS" ]; then
21
+ echo "No non-compliant tags found."
22
+ exit 0
23
+ fi
24
+
25
+ echo "Latest tag (preserved): $LATEST_TAG"
26
+
27
+ for TAG in $TAGS; do
28
+ if [ "$TAG" = "$LATEST_TAG" ]; then
29
+ echo "Skipping tag $TAG (latest tag)"
30
+ continue
31
+ fi
32
+
33
+ SHOULD_DELETE=false
34
+ REASON=""
35
+
36
+ # Rule 1: Current branch is dev or qa
37
+ if [ "$BRANCH" = "dev" ] || [ "$BRANCH" = "qa" ]; then
38
+ SHOULD_DELETE=true
39
+ REASON="on $BRANCH branch"
40
+ fi
41
+
42
+ # Rule 2: Tag's commit is not reachable from any branch
43
+ if [ "$SHOULD_DELETE" = false ]; then
44
+ BRANCHES=$(git branch -a --contains "$TAG" 2>/dev/null)
45
+ if [ -z "$BRANCHES" ]; then
46
+ SHOULD_DELETE=true
47
+ REASON="not on any branch"
48
+ fi
49
+ fi
50
+
51
+ # Rule 3: Tag's commit is already merged into master
52
+ if [ "$SHOULD_DELETE" = false ]; then
53
+ if git merge-base --is-ancestor "$TAG" master 2>/dev/null; then
54
+ SHOULD_DELETE=true
55
+ REASON="merged into master"
56
+ fi
57
+ fi
58
+
59
+ if [ "$SHOULD_DELETE" = true ]; then
60
+ echo "Deleting tag $TAG ($REASON)"
61
+ git push origin --delete "$TAG" --no-verify 2>/dev/null || true
62
+ git tag -d "$TAG"
63
+ else
64
+ echo "Keeping tag $TAG"
65
+ fi
66
+ done
@@ -87,6 +87,12 @@ export default {
87
87
  getVipTable: ({ appSecret }) => ({ url: 'activities/viptable', method: 'get', params: { appSecret } }),
88
88
  getLevelBonusInfo: () => ({ url: 'activities/level-bonus/info', method: 'get' }),
89
89
  getRankingList: () => ({ url: 'activities/ranking', method: 'get' }),
90
+ getPublicRankingList: ({ appSecret }) => ({
91
+ url: 'activities/ranking/public/promotion-ranking',
92
+ method: 'get',
93
+ isPublic: true,
94
+ params: { appSecret },
95
+ }),
90
96
  exchangeDiamond: ({ activityNo, exchangeAward = [] }) => ({
91
97
  url: 'activities/exchange/diamond',
92
98
  method: 'post',
@@ -110,6 +110,28 @@ export default function (request) {
110
110
  },
111
111
  },
112
112
  otpChecking: {
113
+ initial: 'pending',
114
+ states: {
115
+ pending: {
116
+ after: {
117
+ TIMEOUT: {
118
+ target: 'fetching',
119
+ },
120
+ },
121
+ },
122
+ fetching: {
123
+ invoke: {
124
+ src: 'fetchUserInfo',
125
+ onDone: {
126
+ target: 'pending',
127
+ actions: ['setUserInfo', 'extendToken'],
128
+ },
129
+ onError: {
130
+ target: 'pending',
131
+ },
132
+ },
133
+ },
134
+ },
113
135
  on: {
114
136
  OTP_VERIFIED: {
115
137
  target: 'loginSuccess',
@@ -251,8 +251,14 @@ export default function (request, context) {
251
251
  },
252
252
  guards: {
253
253
  isCalculable: (context, event) => {
254
- const { selectedCrypto, selectedAddress, cryptoBank, selectedAmount } = context
255
- return selectedCrypto && selectedAddress && selectedAmount && cryptoBank.minimum <= +selectedAmount && +selectedAmount <= cryptoBank.maximum
254
+ const { selectedCrypto, selectedAddress, selectedAmount } = context
255
+ return (
256
+ selectedCrypto &&
257
+ selectedAddress &&
258
+ selectedAmount &&
259
+ selectedCrypto.minimum <= +selectedAmount &&
260
+ +selectedAmount <= selectedCrypto.maximum
261
+ )
256
262
  },
257
263
  isSubmittable: (context, event) => {
258
264
  const { selectedCrypto, selectedAddress, selectedAmount, depositTime, receipt, calculation, siteConfig } = context
@@ -37,12 +37,13 @@ export default function (request) {
37
37
  checking: {
38
38
  always: [
39
39
  { target: 'idle', actions: 'setActivityDetail', cond: 'isExist' },
40
- { target: 'loading', cond: 'hasActivityNo' },
40
+ { target: 'loading', cond: 'hasActivityNoAndToken' },
41
+ { target: 'idle' },
41
42
  ],
42
43
  },
43
44
  loading: {
44
45
  invoke: {
45
- src: 'fetchPublicActivityDetail',
46
+ src: 'fetchActivityDetail',
46
47
  onDone: {
47
48
  target: 'idle',
48
49
  actions: ['setActivityMap', 'setActivityDetail'],
@@ -100,8 +101,9 @@ export default function (request) {
100
101
  const { activityMap, activityNo } = context
101
102
  return activityMap[activityNo]
102
103
  },
103
- hasActivityNo: (context, event) => {
104
- return !!context.activityNo
104
+ hasActivityNoAndToken: (context, event) => {
105
+ const hasToken = request.getToken()
106
+ return !!context.activityNo && hasToken
105
107
  },
106
108
  },
107
109
  services: {
@@ -116,15 +118,10 @@ export default function (request) {
116
118
  const { data } = await request.send(hasToken ? api.getActivityList({ appSecret }) : api.getAllActivityList({ appSecret }))
117
119
  return data
118
120
  },
119
- fetchPublicActivityDetail: async (context, event) => {
120
- const hasToken = request.getToken()
121
+ fetchActivityDetail: async (context, event) => {
121
122
  const { activityNo } = context
122
123
  let result = {}
123
- if (hasToken) {
124
- result = await request.send(api.getActivityDetail({ activityNo, appSecret }))
125
- } else {
126
- result = await request.send(api.getTournamentDetail({ activityNo, appSecret }))
127
- }
124
+ result = await request.send(api.getActivityDetail({ activityNo, appSecret }))
128
125
  return result.data
129
126
  },
130
127
  },