Skip to content

Commit

Permalink
support for 4.3
Browse files Browse the repository at this point in the history
Changed nft manager to asset manager, supporting both nfts and tokens

Added AccountInspector class for getting clickable links to solscan/explorer/solanafm

TransactionProcessor changed to TransactionManager and it's now much cleaner
  • Loading branch information
ZenRepublic committed Aug 16, 2024
1 parent d08c840 commit 91c71fb
Show file tree
Hide file tree
Showing 87 changed files with 1,976 additions and 2,297 deletions.
38 changes: 0 additions & 38 deletions addons/SolanaSDK/Autoload/SceneLoader.tscn

This file was deleted.

24 changes: 16 additions & 8 deletions addons/SolanaSDK/Autoload/SolanaService.tscn
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
[gd_scene load_steps=7 format=3 uid="uid://b2dmsrk6j12y4"]
[gd_scene load_steps=9 format=3 uid="uid://b2dmsrk6j12y4"]

[ext_resource type="Script" path="res://addons/SolanaSDK/Scripts/Managers/solana_service.gd" id="1_hwc3u"]
[ext_resource type="Script" path="res://addons/SolanaSDK/Scripts/TransactionProcessor/transaction_processor.gd" id="2_v3adq"]
[ext_resource type="Script" path="res://addons/SolanaSDK/Scripts/TransactionProcessor/transaction_manager.gd" id="2_v3adq"]
[ext_resource type="Script" path="res://addons/SolanaSDK/Scripts/Managers/wallet_service.gd" id="5_f327g"]
[ext_resource type="Script" path="res://addons/SolanaSDK/Scripts/Managers/nft_manager.gd" id="6_b1bp1"]
[ext_resource type="Script" path="res://addons/SolanaSDK/Scripts/Utility/account_inspector.gd" id="6_mv3j8"]
[ext_resource type="Script" path="res://addons/SolanaSDK/Scripts/Utility/file_loader.gd" id="7_4sv1b"]
[ext_resource type="Script" path="res://addons/SolanaSDK/Scripts/Managers/asset_manager.gd" id="8_4oy84"]
[ext_resource type="Texture2D" uid="uid://dkyfoudbohuqq" path="res://addons/SolanaSDK/Textures/missingicon.png" id="9_oi842"]
[ext_resource type="Script" path="res://addons/SolanaSDK/Scripts/Managers/candy_machine_manager.gd" id="9_pob61"]

[node name="SolanaService" type="Node"]
script = ExtResource("1_hwc3u")
rpc_cluster = 1
devnet_rpc = "https://api.devnet.solana.com"

[node name="TransactionProcessor" type="Node" parent="."]
script = ExtResource("2_v3adq")

[node name="WalletService" type="Node" parent="."]
script = ExtResource("5_f327g")
use_generated = true

[node name="WalletAdapter" type="WalletAdapter" parent="WalletService"]

[node name="NFTManager" type="Node" parent="."]
script = ExtResource("6_b1bp1")
[node name="AssetManager" type="Node" parent="."]
script = ExtResource("8_4oy84")
load_on_login = true
missing_texture_visual = ExtResource("9_oi842")

[node name="TransactionManager" type="Node" parent="."]
script = ExtResource("2_v3adq")

[node name="FileLoader" type="Node" parent="."]
script = ExtResource("7_4sv1b")

[node name="AccountInspector" type="Node" parent="."]
script = ExtResource("6_mv3j8")

[node name="CandyMachineManager" type="Node" parent="."]
script = ExtResource("9_pob61")
296 changes: 296 additions & 0 deletions addons/SolanaSDK/Demos/1.TokenTransferDemo/TokenTransferDemo.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,296 @@
[gd_scene load_steps=28 format=3 uid="uid://dw5exsao534ov"]

[ext_resource type="Script" path="res://addons/SolanaSDK/Demos/1.TokenTransferDemo/account_manager.gd" id="1_ossju"]
[ext_resource type="FontFile" uid="uid://inxwmykjoa5p" path="res://addons/SolanaSDK/Fonts/Circus Of Innocents.ttf" id="2_d2ki1"]
[ext_resource type="Script" path="res://addons/SolanaSDK/Scripts/Utility/token_visualizer.gd" id="3_no3k2"]
[ext_resource type="Texture2D" uid="uid://c7s56sayh028u" path="res://addons/SolanaSDK/Textures/SolanaLogo.png" id="4_ds0qu"]
[ext_resource type="FontFile" uid="uid://djc4usmv5o2u5" path="res://addons/SolanaSDK/Fonts/PUSSS___.TTF" id="5_ghe3k"]
[ext_resource type="Script" path="res://addons/SolanaSDK/Demos/1.TokenTransferDemo/token_transfer_manager.gd" id="6_d4boe"]
[ext_resource type="Script" path="res://addons/SolanaSDK/Scripts/Utility/input_field_system.gd" id="7_h3u85"]
[ext_resource type="Script" path="res://addons/SolanaSDK/Scripts/Utility/input_field.gd" id="8_1ogk1"]
[ext_resource type="Texture2D" uid="uid://et1kvxp5bprg" path="res://addons/SolanaSDK/Textures/Buttons/b_inactive.PNG" id="9_c2d0u"]
[ext_resource type="Texture2D" uid="uid://d4kauar2qc15y" path="res://addons/SolanaSDK/Textures/Buttons/b_green_hover.PNG" id="10_ahpdt"]
[ext_resource type="Texture2D" uid="uid://cye2pbirpht4u" path="res://addons/SolanaSDK/Textures/Buttons/b_green_pressed.PNG" id="11_kculu"]
[ext_resource type="Texture2D" uid="uid://5erj253phx4s" path="res://addons/SolanaSDK/Textures/Buttons/b_orange_hover.PNG" id="12_tjkal"]
[ext_resource type="Texture2D" uid="uid://dnqcw4msg2uow" path="res://addons/SolanaSDK/Textures/Buttons/b_orange_pressed.PNG" id="13_uo35c"]
[ext_resource type="Script" path="res://addons/SolanaSDK/Scripts/Utility/scene_change_button.gd" id="14_5nxww"]
[ext_resource type="PackedScene" uid="uid://blmw46he11fxs" path="res://addons/SolanaSDK/Scripts/TransactionProcessor/TransactionOverlayUI.tscn" id="15_6yqjf"]
[ext_resource type="Script" path="res://addons/SolanaSDK/Scripts/Utility/scene_loader.gd" id="16_gwjyc"]

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_7pi32"]
bg_color = Color(0.937255, 0.682353, 0.341176, 1)

[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_b04j3"]

[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_m8hje"]
texture = ExtResource("9_c2d0u")

[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_efb31"]
texture = ExtResource("10_ahpdt")

[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_bio0t"]
texture = ExtResource("11_kculu")

[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_hadpj"]
texture = ExtResource("11_kculu")

[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_0xvq3"]

[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_avkrb"]
texture = ExtResource("9_c2d0u")

[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_ryjmu"]
texture = ExtResource("12_tjkal")

[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_f2tob"]
texture = ExtResource("13_uo35c")

[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_bmrj2"]
texture = ExtResource("13_uo35c")

[node name="TokenTransferDemo" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2

[node name="Background" type="Panel" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_7pi32")

[node name="AccountContainer" type="MarginContainer" parent="."]
layout_mode = 1
offset_right = 512.0
offset_bottom = 297.0
theme_override_constants/margin_left = 30
theme_override_constants/margin_top = 30
theme_override_constants/margin_right = 30
theme_override_constants/margin_bottom = 30

[node name="VBoxContainer" type="VBoxContainer" parent="AccountContainer"]
layout_mode = 2

[node name="AccountPanel" type="VBoxContainer" parent="AccountContainer/VBoxContainer"]
layout_mode = 2
script = ExtResource("1_ossju")

[node name="AccountLabel" type="Label" parent="AccountContainer/VBoxContainer/AccountPanel"]
layout_mode = 2
theme_override_fonts/font = ExtResource("2_d2ki1")
theme_override_font_sizes/font_size = 60
text = "Welcome back,"

[node name="AccountAddress" type="Label" parent="AccountContainer/VBoxContainer/AccountPanel"]
layout_mode = 2
theme_override_fonts/font = ExtResource("2_d2ki1")
theme_override_font_sizes/font_size = 23
text = "84pL2GAuv8XGVPyZre2xcgUNSGz9csYHBt5AW4PUcEe9"

[node name="BalanceLabel" type="Label" parent="AccountContainer/VBoxContainer/AccountPanel"]
layout_mode = 2
theme_override_fonts/font = ExtResource("2_d2ki1")
theme_override_font_sizes/font_size = 50
text = "SOL Balance"

[node name="SolBalance" type="HBoxContainer" parent="AccountContainer/VBoxContainer/AccountPanel" node_paths=PackedStringArray("amount_label", "token_visual")]
layout_mode = 2
script = ExtResource("3_no3k2")
amount_label = NodePath("Balance")
token_visual = NodePath("Visual")
auto_update_balance = true
missing_icon_path = "res://addons/SolanaSDK/Textures/missingicon.png"

[node name="Visual" type="TextureRect" parent="AccountContainer/VBoxContainer/AccountPanel/SolBalance"]
layout_mode = 2
texture = ExtResource("4_ds0qu")
expand_mode = 3
stretch_mode = 5

[node name="Spacer" type="MarginContainer" parent="AccountContainer/VBoxContainer/AccountPanel/SolBalance"]
layout_mode = 2
theme_override_constants/margin_right = 20

[node name="Balance" type="Label" parent="AccountContainer/VBoxContainer/AccountPanel/SolBalance"]
layout_mode = 2
theme_override_fonts/font = ExtResource("5_ghe3k")
theme_override_font_sizes/font_size = 55
text = "..."
vertical_alignment = 1

[node name="TransactionContainer" type="MarginContainer" parent="."]
layout_mode = 1
anchors_preset = 12
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = -248.0
grow_horizontal = 2
grow_vertical = 0
theme_override_constants/margin_left = 30
theme_override_constants/margin_top = 0
theme_override_constants/margin_right = 30
theme_override_constants/margin_bottom = 100

[node name="TransactionBoxes" type="HBoxContainer" parent="TransactionContainer"]
layout_mode = 2
theme_override_constants/separation = 60
alignment = 1

[node name="SolTransactionPanel" type="VBoxContainer" parent="TransactionContainer/TransactionBoxes" node_paths=PackedStringArray("input_field_system")]
layout_mode = 2
alignment = 1
script = ExtResource("6_d4boe")
input_field_system = NodePath("InputFieldSystem")

[node name="InputFieldSystem" type="Node" parent="TransactionContainer/TransactionBoxes/SolTransactionPanel" node_paths=PackedStringArray("input_fields", "confirm_button")]
script = ExtResource("7_h3u85")
input_fields = [NodePath("../ReceiverInputField"), NodePath("../AmountInputField")]
confirm_button = NodePath("../MarginContainer/SendButton")

[node name="IntroText" type="Label" parent="TransactionContainer/TransactionBoxes/SolTransactionPanel"]
layout_mode = 2
theme_override_fonts/font = ExtResource("2_d2ki1")
theme_override_font_sizes/font_size = 60
text = "Transfer SOL"
horizontal_alignment = 1
vertical_alignment = 1

[node name="Spacer" type="MarginContainer" parent="TransactionContainer/TransactionBoxes/SolTransactionPanel"]
layout_mode = 2
theme_override_constants/margin_bottom = 30

[node name="ReceiverInputField" type="LineEdit" parent="TransactionContainer/TransactionBoxes/SolTransactionPanel"]
layout_mode = 2
placeholder_text = "Receiver SOL Address..."
alignment = 1
script = ExtResource("8_1ogk1")
min_length = 32

[node name="AmountInputField" type="LineEdit" parent="TransactionContainer/TransactionBoxes/SolTransactionPanel"]
layout_mode = 2
placeholder_text = "Enter amount to send..."
alignment = 1
script = ExtResource("8_1ogk1")
input_type = 2

[node name="MarginContainer" type="MarginContainer" parent="TransactionContainer/TransactionBoxes/SolTransactionPanel"]
layout_mode = 2
theme_override_constants/margin_left = 150
theme_override_constants/margin_right = 150

[node name="SendButton" type="Button" parent="TransactionContainer/TransactionBoxes/SolTransactionPanel/MarginContainer"]
custom_minimum_size = Vector2(200, 80)
layout_mode = 2
theme_override_colors/font_color = Color(1, 1, 1, 1)
theme_override_fonts/font = ExtResource("5_ghe3k")
theme_override_font_sizes/font_size = 35
theme_override_styles/focus = SubResource("StyleBoxEmpty_b04j3")
theme_override_styles/disabled = SubResource("StyleBoxTexture_m8hje")
theme_override_styles/hover = SubResource("StyleBoxTexture_efb31")
theme_override_styles/pressed = SubResource("StyleBoxTexture_bio0t")
theme_override_styles/normal = SubResource("StyleBoxTexture_hadpj")
text = "SEND"

[node name="SplTransactionPanel2" type="VBoxContainer" parent="TransactionContainer/TransactionBoxes" node_paths=PackedStringArray("input_field_system")]
layout_mode = 2
script = ExtResource("6_d4boe")
input_field_system = NodePath("InputFieldSystem")
token_type = 1

[node name="InputFieldSystem" type="Node" parent="TransactionContainer/TransactionBoxes/SplTransactionPanel2" node_paths=PackedStringArray("input_fields", "confirm_button")]
script = ExtResource("7_h3u85")
input_fields = [NodePath("../TokenAddressInputField"), NodePath("../ReceiverInputField"), NodePath("../AmountInputField")]
confirm_button = NodePath("../MarginContainer/SendButton")

[node name="IntroText" type="Label" parent="TransactionContainer/TransactionBoxes/SplTransactionPanel2"]
layout_mode = 2
theme_override_fonts/font = ExtResource("2_d2ki1")
theme_override_font_sizes/font_size = 60
text = "Transfer Custom Token"
horizontal_alignment = 1
vertical_alignment = 1

[node name="Spacer" type="MarginContainer" parent="TransactionContainer/TransactionBoxes/SplTransactionPanel2"]
layout_mode = 2
theme_override_constants/margin_bottom = 30

[node name="TokenAddressInputField" type="LineEdit" parent="TransactionContainer/TransactionBoxes/SplTransactionPanel2"]
layout_mode = 2
text = "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263"
placeholder_text = "Enter Token Address..."
alignment = 1
script = ExtResource("8_1ogk1")

[node name="ReceiverInputField" type="LineEdit" parent="TransactionContainer/TransactionBoxes/SplTransactionPanel2"]
layout_mode = 2
placeholder_text = "Receiver SOL Address..."
alignment = 1
script = ExtResource("8_1ogk1")
min_length = 32

[node name="AmountInputField" type="LineEdit" parent="TransactionContainer/TransactionBoxes/SplTransactionPanel2"]
layout_mode = 2
placeholder_text = "Enter amount to send..."
alignment = 1
script = ExtResource("8_1ogk1")
input_type = 2

[node name="MarginContainer" type="MarginContainer" parent="TransactionContainer/TransactionBoxes/SplTransactionPanel2"]
layout_mode = 2
theme_override_constants/margin_left = 150
theme_override_constants/margin_right = 150

[node name="SendButton" type="Button" parent="TransactionContainer/TransactionBoxes/SplTransactionPanel2/MarginContainer"]
custom_minimum_size = Vector2(200, 80)
layout_mode = 2
theme_override_colors/font_color = Color(1, 1, 1, 1)
theme_override_fonts/font = ExtResource("5_ghe3k")
theme_override_font_sizes/font_size = 35
theme_override_styles/focus = SubResource("StyleBoxEmpty_b04j3")
theme_override_styles/disabled = SubResource("StyleBoxTexture_m8hje")
theme_override_styles/hover = SubResource("StyleBoxTexture_efb31")
theme_override_styles/pressed = SubResource("StyleBoxTexture_bio0t")
theme_override_styles/normal = SubResource("StyleBoxTexture_hadpj")
text = "SEND"

[node name="ReturnButton" type="Button" parent="." node_paths=PackedStringArray("scene_loader")]
layout_mode = 1
anchors_preset = 1
anchor_left = 1.0
anchor_right = 1.0
offset_left = -198.0
offset_top = 18.0
offset_right = -29.0
offset_bottom = 95.0
grow_horizontal = 0
theme_override_colors/font_color = Color(1, 1, 1, 1)
theme_override_fonts/font = ExtResource("5_ghe3k")
theme_override_font_sizes/font_size = 35
theme_override_styles/focus = SubResource("StyleBoxEmpty_0xvq3")
theme_override_styles/disabled = SubResource("StyleBoxTexture_avkrb")
theme_override_styles/hover = SubResource("StyleBoxTexture_ryjmu")
theme_override_styles/pressed = SubResource("StyleBoxTexture_f2tob")
theme_override_styles/normal = SubResource("StyleBoxTexture_bmrj2")
text = "RETURN"
script = ExtResource("14_5nxww")
path_to_scene = "res://addons/SolanaSDK/Demos/_DemoSelectScene/DemoSelectScene.tscn"
scene_loader = NodePath("../SceneLoader")

[node name="TransactionOverlayUI" parent="." instance=ExtResource("15_6yqjf")]

[node name="SceneLoader" type="Node" parent="."]
script = ExtResource("16_gwjyc")

[connection signal="text_changed" from="TransactionContainer/TransactionBoxes/SolTransactionPanel/ReceiverInputField" to="TransactionContainer/TransactionBoxes/SolTransactionPanel/ReceiverInputField" method="_on_text_changed"]
[connection signal="text_changed" from="TransactionContainer/TransactionBoxes/SolTransactionPanel/AmountInputField" to="TransactionContainer/TransactionBoxes/SolTransactionPanel/AmountInputField" method="_on_text_changed"]
[connection signal="text_changed" from="TransactionContainer/TransactionBoxes/SplTransactionPanel2/TokenAddressInputField" to="TransactionContainer/TransactionBoxes/SplTransactionPanel2/TokenAddressInputField" method="_on_text_changed"]
[connection signal="text_changed" from="TransactionContainer/TransactionBoxes/SplTransactionPanel2/ReceiverInputField" to="TransactionContainer/TransactionBoxes/SplTransactionPanel2/ReceiverInputField" method="_on_text_changed"]
[connection signal="text_changed" from="TransactionContainer/TransactionBoxes/SplTransactionPanel2/AmountInputField" to="TransactionContainer/TransactionBoxes/SplTransactionPanel2/AmountInputField" method="_on_text_changed"]
[connection signal="pressed" from="ReturnButton" to="ReturnButton" method="_on_pressed"]
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ func _ready() -> void:
#SolanaClient.account_subscribe(SolanaService.wallet.get_pubkey(),Callable(self,"update_balance"))
var balance:float
if balance_token_address.length()==0:
balance = await SolanaService.get_sol_balance(wallet_address)
balance = await SolanaService.get_balance(wallet_address)
balance_visualizer.set_token_data(balance)
else:
balance = await SolanaService.get_token_balance(wallet_address,balance_token_address)
balance = await SolanaService.get_balance(wallet_address,balance_token_address)
balance_visualizer.set_token_data(balance,Pubkey.new_from_string(balance_token_address))

#func update_balance(account_data:Dictionary) -> void:
Expand Down
Loading

0 comments on commit 91c71fb

Please sign in to comment.